Java SQLITE_错误SQL错误或缺少数据库(没有这样的表:用户)

Java SQLITE_错误SQL错误或缺少数据库(没有这样的表:用户),java,database,sqlite,tomcat,Java,Database,Sqlite,Tomcat,希望有人能帮忙。我试图从Eclipse中的动态Web项目访问我的数据库。出于某种原因,我不断收到以下错误: [SQLITE_ERROR]SQL错误或缺少数据库(没有这样的表:用户) 图书数据库中肯定有一个名为“users”的表。我认为这可能与我保存数据库的位置有关,因为我知道我使用的代码工作得很好,因为我在项目的另一部分中使用了它。下面的屏幕截图显示保存内容的位置。我的数据库位于主目录和web inf目录中,因为我的主程序需要访问它和服务器 我的代码: public class Authent

希望有人能帮忙。我试图从Eclipse中的动态Web项目访问我的数据库。出于某种原因,我不断收到以下错误:

[SQLITE_ERROR]SQL错误或缺少数据库(没有这样的表:用户)

图书数据库中肯定有一个名为“users”的表。我认为这可能与我保存数据库的位置有关,因为我知道我使用的代码工作得很好,因为我在项目的另一部分中使用了它。下面的屏幕截图显示保存内容的位置。我的数据库位于主目录和web inf目录中,因为我的主程序需要访问它和服务器

我的代码:

public class Authentication {

    private static Connection getDBConnection() {

        Connection conn = null;

        try {
            Class.forName("org.sqlite.JDBC");
        } catch (ClassNotFoundException e) {
            System.out.println(e.getMessage());
        }

        try {
            String url = "jdbc:sqlite:books.sqlite";
            //Gets connection with the JDBC API
            conn = DriverManager.getConnection(url);
        } catch (SQLException e) {
            System.out.println(e.getMessage());
        }

        return conn;
    }

    public String authenticate(String username, String password) throws SQLException {

        // TODO maybe removed this line below or change it. 

                Statement statement = null;
                Connection conn = null;
                ResultSet results = null;
                HashMap<String,String> userPass = new HashMap<String,String>();

                // Creates SQL query and adds it to String variable.
                String query = "SELECT username, password FROM users";
                // TODO Maybe remove the below line, not necessary?
                // Book temp = null;

                try {                       
                    conn = getDBConnection();   
                    statement = conn.createStatement();                     
                    results = statement.executeQuery(query);                    
                    while (results.next()) {                        
                        String Username = results.getString("username");
                        String Password = results.getString("password");                            
                        userPass.put(Username, Password);
                    }
                } finally {
                    if (results != null)
                        results.close();
                    if (statement != null)
                        statement.close();
                    if (conn != null)
                        conn.close();
                }
                //Returns to newly created bookList to where the method was called.

                if (userPass.get(username)== password ) {
                    return "success";
                }
                else {
                    return "error";
                }               
    }
}
公共类身份验证{
私有静态连接getDBConnection(){
连接conn=null;
试一试{
Class.forName(“org.sqlite.JDBC”);
}catch(classnotfounde异常){
System.out.println(e.getMessage());
}
试一试{
String url=“jdbc:sqlite:books.sqlite”;
//获取与JDBCAPI的连接
conn=DriverManager.getConnection(url);
}捕获(SQLE异常){
System.out.println(e.getMessage());
}
返回连接;
}
公共字符串身份验证(字符串用户名、字符串密码)引发SQLException{
//TODO可能会删除或更改下面的这一行。
Statement=null;
连接conn=null;
ResultSet results=null;
HashMap userPass=新的HashMap();
//创建SQL查询并将其添加到字符串变量。
String query=“从用户中选择用户名、密码”;
//TODO可能删除下面的行,没有必要吗?
//书本温度=空;
试试{
conn=getDBConnection();
statement=conn.createStatement();
结果=语句.executeQuery(查询);
while(results.next()){
字符串用户名=results.getString(“用户名”);
字符串密码=results.getString(“密码”);
userPass.put(用户名、密码);
}
}最后{
如果(结果!=null)
结果:关闭();
if(语句!=null)
语句。close();
如果(conn!=null)
康涅狄格州关闭();
}
//返回到调用该方法的新创建的bookList。
if(userPass.get(username)=密码){
返回“成功”;
}
否则{
返回“错误”;
}               
}
}

在SQLite控制台中尝试。您可能需要在mysqliteadminuser.user syntaxHi的表名-select*之前指定用户或模式,在控制台中测试它是个好主意。不过在那里似乎效果不错吧?您能否通过指定用户来澄清您的意思?我需要它来拉所有用户,所以除非我误解了这是行不通的,不是吗?您可能需要指定要查询的数据库的名称。对你来说,似乎是“书”?也许可以试试“从books.users中选择”?谢谢你回复我。不幸的是,我得到了一个类似的错误[SQLITE_error]SQL错误或缺少数据库(没有这样的表:books.users)。我的数据库是否存储在第一张图片的正确位置?你知道吗?