I am trying to run a simple sql query but am getting a Null pointer exception. I tried to change everything possible but could not figure out the reason for this exception.
My part of code :
String sql = "Insert into CG (Date,Day,Pre,Sub) values (?,?,?,?)";
try{
pst = conn.prepareStatement(sql);
pst.setString(1, "date");//4 value taken as input
pst.setString(2, "day");
pst.setString(3, "1");
pst.setString(4, "0");
pst.execute();
}catch (Exception ex) {
JOptionPane.showMessageDialog(null, ex);
}
Edit : I am getting NPE at line pst = conn.prepareStatement(sql)
My connection is :
Connection conn = DriverManager.getConnection("jdbc:sqlite:E:\\NetBeansProject\\At\\At.sqlite");