java sql 错误或缺少数据库(未找到此类表)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41938135/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 06:15:40  来源:igfitidea点击:

sql error or missing database (no such table found)

javajdbc

提问by Aparajit Garg

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??

我正在处理 Eclipse 并在 Windows 10 64 位操作系统上使用 sqlite 作为数据库。现在,当我尝试从我的数据库中获取所有值时,它显示没有这样的表但正在建立连接的消息。我该怎么办??

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);
}

采纳答案by OVK.Ravindu

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 srcfolder. When I move it from my srcfolder to my project folder, my error is solved.

请将您的数据库文件复制到您的项目文件夹中。我遇到了同样的错误。该错误的原因是因为我的 sqlite 数据库文件在我的src文件夹中。当我将它从我的src文件夹移动到我的项目文件夹时,我的错误就解决了。

回答by Efrain Restrepo

change this conn=DriverManager.getConnection("jdbc:sqlite:C://Users//APARAJIT//Desktop//Projects//kbcc.sqlite");

改变这个 conn=DriverManager.getConnection("jdbc:sqlite:C://Users//APARAJIT//Desktop//Projects//kbcc.sqlite");

test

测试

conn=DriverManager.getConnection("jdbc:sqlite:C://Users/APARAJIT/Desktop/Projects/kbcc.sqlite");

my example:

我的例子:

String url = "jdbc:sqlite:C://sqlite/db/datosplayer.db";

回答by JustGimmeTheAnswer

Query your database directly from the schema that your program uses, with the exact statement you have in your code. That way you can figure out if you actually created the table already or not.

直接从您的程序使用的架构中查询您的数据库,并使用您在代码中的确切语句。这样您就可以确定您是否已经实际创建了该表。

回答by Rahul Karande

You need to check the table name spell or table does exist or not please

您需要检查表名拼写或表是否存在请

回答by Shawn

If your connection is good, then your table name is not.

如果您的连接良好,那么您的表名就不是。

Check the spelling of the table you're using. Check the case of your table and column names. Names are case sensitive.

检查您正在使用的表格的拼写。检查表名和列名的大小写。名称区分大小写。

You can verify these through a SQLite browser/GUI.

您可以通过 SQLite 浏览器/GUI 验证这些。