Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sql error or missing database (no such table found)

Tags:

java

jdbc

I am working on eclipse and using sqlite as database on windows 10 64 bit operating system. Now when i try to get all values from my database it shows the message that there is no such table but the connection is being established. What should i do??

try {
    Class.forName("org.sqlite.JDBC");
    conn=DriverManager.getConnection("jdbc:sqlite:C://Users//APARAJIT//Desktop//Projects//kbcc.sqlite");
} catch (Exception e) {
    JOptionPane.showMessageDialog(null,"can't open database");
}

try {
    Statement stmt = mycon.createStatement();
    String sql = "SELECT * FROM record";
    PreparedStatement pst = mycon.prepareStatement(sql);
    ResultSet rs = pst.executeQuery();

    rs.close();
    pst.close();
    stmt.close();
} catch (Exception e) {
    JOptionPane.showMessageDialog(frame, e);
}
like image 698
Aparajit Garg Avatar asked Oct 19 '25 04:10

Aparajit Garg


1 Answers

path to project folder

Please copy your database file to your project folder. I faced the same error. The reason for that error is because of my sqlite database file being in my src folder. When I move it from my src folder to my project folder, my error is solved.

like image 91
OVK.Ravindu Avatar answered Oct 20 '25 18:10

OVK.Ravindu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!