我正在使用servlet和jdbc设计简单的银行应用程序 因此,在将数据插入数据库时,我在preparedStatement
中获得空指针异常我的代码是
Connection con=null;
PreparedStatement preparedStatement =null;
try
{
con = DBConnection.createConnection();
String query = "insert into cst_details(name,surname,aadhar_no,contact_no,address,balance) "
+ "values (?,?,?,?,?,?)";
preparedStatement = con.prepareStatement(query);
preparedStatement.setString(1, name);
preparedStatement.setString(2, surname);
preparedStatement.setString(3, aadhar_no);
preparedStatement.setString(4, contact_no);
preparedStatement.setString(5, address);
preparedStatement.setString(6,initial_bal);