Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 22
Registered: ‎03-02-2010
My Device: Bold 9700
My Carrier: AT&T

Exception being thrown on Database.beginTransaction()

Hi all -


I am stumped on a problem I am having with SQLite.

I have a SQLManager class I have defined that has


    private Database _db = null;


as a data member. I initialize the database properly. I have a getter method, getDB(boolean checkConnection) which does a validity check to make sure that my Database object is OK prior to my using it.


Now, the Database class is an Interface - what gets returned by all the database operations is DatabaseImpl which we can only access via the interface methods provided. DatabaseImpl has 2 internal data members - db (which is a SQLite handle) and dbConn (which is a DatabaseConnection).


These internal data members could, for some reason, become invalid, therefore, just checking if my _db member is not null is not sufficient to know if I have a good database connection. This is why my validity check looks like this:


    protected boolean dbConnectionIsValid() throws Exception {
        try {
            if (_db == null) {
                return false;
            Statement st = _db.createStatement("select current_timestamp");
            return true;
        catch(Exception e) {
            // if anything went wrong, assume the connection is invalid, log it and return false
            msgDialog("dbConnectionIsValid()::caught exception, returning false::" + e.toString());
            return false;


I run a simple "select timestamp" query to return the current time and date, and if that works, I am good, otherwise I just assume that the connection is bad and I try to reopen it.


(FYI - I filed issue JAVAAPI-1206 with RIM months ago to address the inability to detect the state of the DatabaseConnection...)


The validity check returns true and the _db member apepars to be valid but when I call the following:


            Database db = getDB(true);


I catch net.rim.device.api.database.DatabaseException: : SQL logic error or missing database

on the beginTransaction method.


Why is this happening and what can I do about it?