Welcome!

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

Reply
Contributor
Posts: 45
Registered: ‎11-10-2010
My Device: Not Specified

while connecting to SQLITE database shows the error

while connecting to SQLITE database shows the error "net.rim.device.api.database.Database Exception:INSERT INTO people(name,age) values ('Arun',23)Smiley FrustratedQL logic error or missing database"

 

 

Code:

 

  Database d;
            try
            {
            URI myURI = URI.create("file:///store/Databases/sqldb/" +"sampleapp.sqlite");
            d = DatabaseFactory.open(myURI);
            Statement st = d.createStatement("INSERT INTO people(name,age) VALUES ('John',37)");
            st.prepare();
             st.execute();
            st.close();
            d.close();
            add(new RichTextField("Values Inserted"));
            }
            catch ( Exception e )
            {
            System.out.println( e.getMessage() );
            e.printStackTrace();
            add(new RichTextField("Error: "+e.toString()));
            }

Developer
Posts: 254
Registered: ‎03-15-2011
My Device: simulator
My Carrier: simulator

Re: while connecting to SQLITE database shows the error

First Download the SQLite Database browser in your desktop and Check Ur Database is Successfully created with the table 'people' or not. then try to insert the values.
------------------------------------------------------------------------------------------------
Click "Accept as Solution" if post was what you needed. Give kudos if you feel response is helpful.

Contributor
Posts: 45
Registered: ‎11-10-2010
My Device: Not Specified

Re: while connecting to SQLITE database shows the error

Changed the code as follow as

if (DatabaseFactory.exists(myURI)) {
d = DatabaseFactory.open(myURI);
Statement s1 = d.createStatement("INSERT INTO people(name,age) " +
"VALUES ('Uttam','23')");
s1.prepare();
s1.execute();
s1.close();
d.close();
}
else
{
//something...
}

always the program return true for the if condition
so the database exist and try to insert the values but when crossed checked with SQLITE Manager it doesn't have the inserted values...
Developer
Posts: 254
Registered: ‎03-15-2011
My Device: simulator
My Carrier: simulator

Re: while connecting to SQLITE database shows the error

Are u able to insert the rows with the same query through the Sqlite manager??

 

Also check if the age is text or numeric.. If numeric value , remove the single quote and try

------------------------------------------------------------------------------------------------
Click "Accept as Solution" if post was what you needed. Give kudos if you feel response is helpful.

Contributor
Posts: 45
Registered: ‎11-10-2010
My Device: Not Specified

Re: while connecting to SQLITE database shows the error

when i run the same insert command in the SQLITE Manager it works... but pro grammatically not works and also checked age is text