Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public final class TestDerbyJDBI {
- @Test
- public void testNullValueInQuery() throws SQLException {
- DBI dbi = new DBI("jdbc:derby:memory:TestDatabase;create=true");
- TestDAO dao = dbi.open(TestDAO.class);
- dao.createTestTable();
- dao.insertMessage(1, "message1");
- dao.insertMessage(2, null);
- }
- public interface TestDAO {
- @SqlUpdate("create table testtable (id integer, message varchar(512))")
- void createTestTable();
- @SqlUpdate("insert into testtable (id, message) values (:id,:message)")
- void insertMessage(@Bind("id") int id, @Bind("message") String message);
- }
- }
- public final class TestDerbyJDBC {
- @Test
- public void testNullValueInQuery() throws SQLException {
- Connection connection = DriverManager.getConnection("jdbc:derby:memory:TestDatabase;create=true");
- connection.createStatement().executeUpdate("create table testtable (id integer, message varchar(512))");
- PreparedStatement statement = connection.prepareStatement("insert into testtable (id, message) values (?,?)");
- statement.clearParameters();
- statement.setInt(1, 1);
- statement.setString(2, null);
- statement.executeUpdate();
- }
- }
Add Comment
Please, Sign In to add comment