mysql+prepare+statement_prepareStatement 返回空指针 jsp+mysql

我的代码如下

我的代码如下

try{

Class.forName("com.mysql.jdbc.Driver");

String url ="jdbc:mysql://localhost/first?user=root&password=12345&useUnicode=true&characterEncoding=8859_1" ;

Connection conn= DriverManager.getConnection(url);

PreparedStatement pstmt1=null;

String sqlStatement = "insert into applicants(email,pw,question,answer)values(?,?,?,?)";

pstmt1 = conn.prepareStatement(sqlStatement);

pstmt1.setString(1,"a");

pstmt1.setString(2,"b");

pstmt1.setString(3,"c");

pstmt1.setString(4,"d");

pstmt1.executeUpdate();

// out.print("insert complete");

pstmt1.close();

conn.close();

}

catch(Exception e){

out.print(e);

}

%>

not bad

执行时Hello java.lang.NullPointerException not bad

请问怎么解决???

展开

你可能感兴趣的:(mysql+prepare+statement_prepareStatement 返回空指针 jsp+mysql)