I am creating a registration form but getting errors when i’m inserting into the database. I have created the following code:
try {
Class.forName("org.sqlite.JDBC");
connection = DriverManager.getConnection("jdbc:sqlite:C:/apache-tomcat-7.0.33/bin/dbit.db");
insertDB = "INSERT INTO users VALUES('" + username + "', '" + password + "');";
Statement st = connection.createStatement();
st.executeUpdate(insertDB);
} catch(ClassNotFoundException e){
System.out.println("ClassNotFoundException");
} catch (SQLException e){
System.out.println("SQLException");
e.printStackTrace();
}
I have a database file with the name dbit in the bin folder in the Apache folder. This database file is created with Sqliteman-1.2.2 and I got two files (dbit file 3kb and dbit.db 0kb).
I want to insert the username and password in the database but I’m getting an SQLException. In the stacktrace: SQLExcepton: no such table: users. But that table does exist in the database.
I found the solution..
SQLiteman-1.2.2 creates two database files, one database.db and database (without extension). I used the .db file but that didn’t work, then changing the line:
to:
Solved my problem.