0

First of all i would like to tell my apologies for asking this simple question. i am trying to connect sql-lite database table.I am using following code.

package derb;
import java.sql.*;
public class db {
    public static void main(String[] args) throws Exception {
        Class.forName("org.sqlite.JDBC");
        Connection con=DriverManager.getConnection("jdbc:sqlite:/home/anand/MySQLiteDB.TEST","root","ROOT");
        Statement st=con.createStatement();
        String q="insert into CHECKING values(3)";
        st.executeUpdate(q);
    }

}

TEST is my database and i created one table called CHECKING in eclipse.but in above code gives me the error

Exception in thread "main" java.sql.SQLException: no such table: CHECKING
    at org.sqlite.DB.throwex(DB.java:288)
    at org.sqlite.NativeDB.prepare(Native Method)
    at org.sqlite.DB.prepare(DB.java:114)
    at org.sqlite.Stmt.executeUpdate(Stmt.java:102)
    at derb.db.main(db.java:9)

I manually checked in the eclipse the table was available.but i don't know how to make the connection to that table.So any one can help me to fix this

Thank you

2
  • What happens if you try to run the same statement through the sqlite command line interface?
    – user253751
    Jan 6, 2016 at 10:08
  • @immibis in eclipse i generated ddl (.sql) file and write my queries it will execute correctly.I think the problem is in my connection string that's why my table not detected
    – KVK
    Jan 6, 2016 at 10:11

1 Answer 1

0

just now i come to know my mistake i just remove my db name from the connection string it works fine for me.

Connection con=DriverManager.getConnection("jdbc:sqlite:/home/anand/MySQLiteDB.TEST","root","ROOT");

changed to

    Connection con=DriverManager.getConnection("jdbc:sqlite:/home/anand/MySQLiteDB","root","ROOT");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.