jbrodriguez/react-native-android-sqlite

DBManager.exec() not found

leoabacade opened this issue · 3 comments

after succeed init with a db, I got below error messages when I tried to use exec or query my table

Callback with id 5: DBManager.exec() not found__invokeCallback @ MessageQueue.js:163
ExceptionsManager.js:67 Error: Cannot read property 'apply' of null
 stack: 
  MessageQueue.__invokeCallback                     index.android.bun…:5597
  <unknown>                                         index.android.bun…:5528
  guard                                             index.android.bun…:5466
  MessageQueue.invokeCallbackAndReturnFlushedQueue  index.android.bun…:5528
  messageHandlers.executeJSCall                     debugger-ui:66
  WebSocket.ws.onmessage                            debugger-ui:93
 URL: undefined
 line: undefined
 message: Cannot read property 'apply' of null

my react-native version is 0.11.4
build on 'Nexus 6 - 5.0.1'

below is how I implement the functions

var db = "test1.db";
var tbl1 = "tbl1";

sqlite.init(db).then((_) => {

              console.log('database initialized.')

              var sql1 = "select * from"+ tbl1;
              var params = [1];

              sqlite.query(sql1, params).then((rowData) => {
                      console.log('sqlite.query')
                      console.log("Got row data:", rowData);
                  }
              )

          }
      )

@leoabacade , not sure why you're getting the error.

Could you try looking at the log in the android console, to see what exception is being logged ?

$ adb shell
# logcat

So this error gets displayed when the column name or table doesn't exist in the database. For example, if you run a query for a column "FOO" in a table "BAR" and your database exists but doesn't contain a table "BAR" with column "FOO", you will get this error.

Looking at the code above, it seems that the sql statement doesn't have a space between the from and the tb1 variable (resolving to something like SELECT * FROMtbl1) which triggers this type of error.

@jbrodriguez, you may want to close this issue - since it's just related to basic error handling.

Looking at the code above, it seems that the sql statement doesn't have a space between the from and the tb1 variable (resolving to something like SELECT * FROMtbl1) which triggers this type of error

Oh, that's right.

Thanks @rhaker !