Advertisement
Guest User

Untitled

a guest
Dec 17th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. @Test(expected = SQLException.class)
  2. public void testUsingStatemenThroughClosedConnection() throws SQLException {
  3. Driver driver = new Driver();
  4. java.sql.Connection connection = driver.connect("jdbc:altdb://localhost", new Properties());
  5. java.sql.Statement statement = connection.createStatement();
  6. statement.executeQuery("create Database school");
  7. statement.executeQuery("use school");
  8. statement.executeQuery("create table students(id int, Name varchar, Birthday Date))");
  9. statement.executeQuery("insert into students values(1,\"Bill\", 2008-07-27)");
  10. connection.close();
  11. statement.executeQuery("select * from students");
  12. }
  13.  
  14. @Test(expected = SQLException.class)
  15. public void testUsingClosedStatement() throws SQLException {
  16. Driver driver = new Driver();
  17. java.sql.Connection connection = driver.connect("jdbc:altdb://localhost", new Properties());
  18. java.sql.Statement statement = connection.createStatement();
  19. statement.executeQuery("create Database school");
  20. statement.executeQuery("use school");
  21. statement.executeQuery("create table students(id int, Name varchar, Birthday Date))");
  22. statement.executeQuery("insert into students values(1,\"Bill\", 2008-07-27)");
  23. statement.close();
  24. statement.executeQuery("select * from students");
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement