preparedStatement处的空指针异常

时间:2018-02-20 04:34:15

标签: java mysql servlets jdbc

我正在使用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);

0 个答案:

没有答案