Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Test(expected = SQLException.class)
- public void testUsingStatemenThroughClosedConnection() throws SQLException {
- Driver driver = new Driver();
- java.sql.Connection connection = driver.connect("jdbc:altdb://localhost", new Properties());
- java.sql.Statement statement = connection.createStatement();
- statement.executeQuery("create Database school");
- statement.executeQuery("use school");
- statement.executeQuery("create table students(id int, Name varchar, Birthday Date))");
- statement.executeQuery("insert into students values(1,\"Bill\", 2008-07-27)");
- connection.close();
- statement.executeQuery("select * from students");
- }
- @Test(expected = SQLException.class)
- public void testUsingClosedStatement() throws SQLException {
- Driver driver = new Driver();
- java.sql.Connection connection = driver.connect("jdbc:altdb://localhost", new Properties());
- java.sql.Statement statement = connection.createStatement();
- statement.executeQuery("create Database school");
- statement.executeQuery("use school");
- statement.executeQuery("create table students(id int, Name varchar, Birthday Date))");
- statement.executeQuery("insert into students values(1,\"Bill\", 2008-07-27)");
- statement.close();
- statement.executeQuery("select * from students");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement