Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stata 18 - JDBC inconsistent error message

    I am accessing a locally stored SQLite data base with JDBC:
    Code:
    clear
    local jar "sqlite-jdbc-3.36.0.3.jar"
    local driverclass "org.sqlite.JDBC"
    local url "jdbc:sqlite://C:/autotransplant.sqlite"
    
    local user "user"
    local pass "password"
    jdbc connect, jar("`jar'") driverclass("`driverclass'") url("`url'") user("`user'") password("`pass'")
    
    jdbc showtables
    jdbc describe "summary"
    jdbc load, table("summary")
    and it appears to fail with an error message when loading the dataset:
    Code:
    . jdbc showtables
    
    Database: null
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Tables
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    summary
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    . jdbc describe "summary"
    
    Table: summary
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Column name                                Column type
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    pid                                        INTEGER
    source                                     TEXT
    paper                                      TEXT
    year                                       INTEGER
    total                                      INTEGER
    succ_pc                                    REAL
    succ_n                                     INTEGER
    surv_pc                                    REAL
    surv_n                                     INTEGER
    ank_pc                                     REAL
    ank_n                                      INTEGER
    res_pc                                     REAL
    res_n                                      INTEGER
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    . jdbc load, table("summary")
    (191 observations loaded)
    failed to load dataset
        SQLite JDBC: inconsistent internal state
    r(683);
    yet the dataset is there and I can use it.
    Code:
    . d
    
    Contains data
     Observations:           191                  
        Variables:            13                  
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Variable      Storage   Display    Value
        name         type    format    label      Variable label
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    pid             long    %12.0g                pid
    source          strL    %9s                   source
    paper           strL    %9s                   paper
    year            long    %12.0g                year
    total           long    %12.0g                total
    succ_pc         double  %9.0g                 succ_pc
    succ_n          long    %12.0g                succ_n
    surv_pc         double  %9.0g                 surv_pc
    surv_n          long    %12.0g                surv_n
    ank_pc          double  %9.0g                 ank_pc
    ank_n           long    %12.0g                ank_n
    res_pc          double  %9.0g                 res_pc
    res_n           long    %12.0g                res_n
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sorted by: 
         Note: Dataset has changed since last saved.
    What am I doing wrong to get this error message?

    Thank you.

    Martyn

    Stata 18/BE

  • #2
    I can't reproduce your error. Can you run the below do-file and see if it works for you? If it doesn't work, can you send the Stata output to [email protected]?

    Code:
    clear all
    
    q compilenumber
    set obs 100
    
    gen double x = rnormal()
    
    gen str1 y = cond(runiform()<0.5, "A", "B")
    
    local jar "sqlite-jdbc-3.40.1.0.jar"
    local driverc "org.sqlite.JDBC"
    tempfile tmpdb
    local url "jdbc:sqlite:`tmpdb'"
    local user "user"
    local pass "password"
    
    jdbc connect, jar("`jar'") driverclass("`driverc'") url("`url'") user("`user'") password("`pass'")
    
    jdbc exec "CREATE TABLE tbl1 (x REAL, y TEXT);"
    jdbc insert, table("tbl1")
    jdbc showtables
    jdbc describe "tbl1"
    
    clear
    
    jdbc load, table("tbl1")
    
    exit


    Comment


    • #3
      This code runs perfectly. However, if I replace the jar with the one that I was using, "sqlite-jdbc-3.36.0.3.jar" I get an error message:

      Code:
      . 
      . jdbc load, table("tbl1")
      (100 observations loaded)
      failed to load dataset
          SQLite JDBC: inconsistent internal state
      r(683);
      
      end of do-file
      
      r(683);
      So I assume that it is a problem with the 'jar'

      Thank you.
      Martyn

      Comment

      Working...
      X