Я подключаю свой код Java к базе данных SQLite, все работает нормально, но выдается исключение, и пользователю выдается сообщение об ошибке, почему мой код выдает это исключение?
public static void main(String[] args) {
Connection c = null;
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:admin.db");
System.out.println("Connection established");
String cmd = "INSERT INTO admins(user_name, password)"
+ "VALUES('TinoCle','1234')";
Statement stmt = c.createStatement();
//Executes my command "cmd"
stmt.execute(cmd);
//Sends it to the db
c.commit();
//Close connection
stmt.close();
c.close();
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
catch (SQLException e) {
//This message is showing up, but it shouldn't
System.out.println("Connection to DB failed");
System.exit(0);
}
}