The following is the ejbCreate() method of an entity bean with BMP. (I'm running this code on WLS6.1 with a MySQL DB v.3.23.):
public AddPK ejbCreate(
String carAddId, ...) throws CreateException {
PreparedStatement pStmt = null;
Connection conn = null;
String sql_INS = "INSERT INTO test.CarAdd VALUES(?, ?, ?)";
try {
conn = getConnection();
pStmt = conn.prepareStatement(sql_INS);
//...
pStmt.setString(1, carAddId);
//...
//executeUpdate()...
return new AddPK(carAddId);
}
catch (Exception e) {
throw new CreateException(e.toString());
}
finally {
try { if (pStmt != null) pStmt.close(); }
catch (Exception e) {}
try { if (conn != null) conn.close(); }
catch (Exception e) {}
}
....................................
The problem is the "conn.prepareStatement(sql_INS)" part: I just can't seem to get what's wrong with the sql_INS query?! A NullPointerException is thrown from this clause (it seems...), cuz the program control doesn't seem to get past "pStmt = conn.prepareStatement(sql_INS)"
The connection is perfectly ok (I've tried with getMetaData and so forth).
Is there anyone that kindly could explain what's going on?!?