Reputation: 35
I try to add a new data into SQLite Database. The connection is established successfully, however, when I add new data, nothing is shown in the DB table. Can anyone help me to solve this problem? Thank you
package database;
import java.sql.*;
public class Database {
public static void main(String[] args) {
// TODO code application logic here
Connection c = null;
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:admin.db");
System.out.println("Connection is established");
String SQLadd = "insert into" + "admins(user_name,password)" + "values('sachin', 'kafle')";
Statement stmt = c.createStatement();
stmt.executeUpdate(SQLadd);
//c.commit();
//c.close();
}
catch (Exception e) {
System.out.println("Can not connect to database");
//System.exit(0);
}
}
}
Upvotes: 0
Views: 56
Reputation: 614
I think you should give space between into
and admins
, also after values
, or just do like following :
String SQLadd = "insert into admins(user_name,password) values('sachin', 'kafle')";
Hope it helps... :)
Upvotes: 1