insert null into Integer column using JDBC - final code review
This commit is contained in:
parent
07af5a2687
commit
1a6361606c
@ -21,10 +21,12 @@ public class InsertNullUnitTest {
|
||||
preparedStatement.setInt(1, person.getId());
|
||||
preparedStatement.setString(2, person.getName());
|
||||
preparedStatement.setString(3, person.getLastName());
|
||||
if (person.getAge() == null)
|
||||
if (person.getAge() == null){
|
||||
preparedStatement.setNull(4, Types.INTEGER);
|
||||
else
|
||||
}
|
||||
else{
|
||||
preparedStatement.setInt(4, person.getAge());
|
||||
}
|
||||
int noOfRows = preparedStatement.executeUpdate();
|
||||
|
||||
assertThat(noOfRows, equalTo(1));
|
||||
|
Loading…
x
Reference in New Issue
Block a user