我的连接代码:
try {
Connection con = DriverManager.getConnection("jdbc:sqlite:myDB.sqlite");
PreparedStatement pstm = con.prepareStatement("insert into hell(username,pssword) " +
"values ('"+tfUname.getText()+"','"+tfUpass.getText()+"')");
pstm.close();
con.close();
JOptionPane.showMessageDialog(null,"Congrats, you have been registered succesfully");
RegisterWindow rw = new RegisterWindow();
rw.setVisible(false);
pack();
dispose();
} catch(SQLException ex) {
setTitle(ex.toString());
}
这只是一个将用户名和密码插入数据库的窗口。当我点击按钮时,会出现以下异常:
"java.sql.SQLException: No suitable driver found for jdbc:sqlite:C\\LoginJava2\\myDB.sqlite"
我找到了一个在Java中连接SQLite数据库的例子,它很好用。我正在WindowBuilder(Eclipse)中进行此操作,使用与示例相同的驱动程序。我尝试了不同的驱动程序,但该消息仍然出现。