Please help me!
I have to insert a NULL value into a column of a database.
I tried this:
String personId = "p0815";
String value1 = "test1";
String value2 = "test2";
String value3 = null;
String SQL_String = "'" + person + "'" + ",'" + value1 + "'" + ",'" + value2 + "'" + ",'" + value3 + "'";
Connection con = null;
con = DriverManager.getConnection(url, id, pw);
Statement stmt = con.createStatement();
stmt.executeUpdate(SQL_String);
I get an error that says: value cannot be a null value
Can this problem be solved by using a prepared statement and using the setNull method ? How does it work?
Thanks a lot!
I have to insert a NULL value into a column of a database.
I tried this:
String personId = "p0815";
String value1 = "test1";
String value2 = "test2";
String value3 = null;
String SQL_String = "'" + person + "'" + ",'" + value1 + "'" + ",'" + value2 + "'" + ",'" + value3 + "'";
Connection con = null;
con = DriverManager.getConnection(url, id, pw);
Statement stmt = con.createStatement();
stmt.executeUpdate(SQL_String);
I get an error that says: value cannot be a null value
Can this problem be solved by using a prepared statement and using the setNull method ? How does it work?
Thanks a lot!