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
Developer
anta40
Posts: 224
Registered: ‎07-26-2010
My Device: Z10

Cannot insert data into table: SQL logic error

Now I'm playing with SQLite. I already created the table, and wanted to put data into it.

 

Statement stmt = null;
			
			try {
				URI uri = URI.create("/SDCard/BlackBerry/album.db"); 
				db = DatabaseFactory.open(uri);
				db.beginTransaction();
				stmt = db.createStatement("INSERT INTO album(album_ID, album_key) " +
                        "VALUES ("+ editID.getText() +","+ editKey.getText() +")" );
				stmt.prepare();
				stmt.execute();
				
				Dialog.inform("Database has been updated!");
			}
			catch (DatabaseIOException dbioe){
				System.out.println(dbioe.getMessage());
			}
			catch (MalformedURIException me){
				System.out.println(me.getMessage());
			}
			catch (DatabaseException dbe){
				System.out.println(dbe.getMessage());
			}
			finally {
				try {
					stmt.close();
					db.commitTransaction();
					db.close();
				} catch (DatabaseException e) {
					e.printStackTrace();
				}
			}
		}

 Every time I run the code, I get this "SQL logic error or missing database". Any help?

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Cannot insert data into table: SQL logic error

i would suggest that you test your code with an sql manager, i use sqlite manager (a firefox plugin)
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter