Exemple #1
0
 static void drop(DataSource ds) throws SQLException {
   Connection con = null;
   Statement stmt = null;
   try {
     con = ds.getConnection();
     stmt = con.createStatement();
     stmt.executeUpdate("DROP TABLE TRSS_TABLE");
   } finally {
     StatementUtils.attemptClose(stmt);
     ConnectionUtils.attemptClose(con);
   }
 }
Exemple #2
0
 static void create(DataSource ds) throws SQLException {
   Connection con = null;
   Statement stmt = null;
   try {
     con = ds.getConnection();
     stmt = con.createStatement();
     stmt.executeUpdate("CREATE TABLE TRSS_TABLE ( a_col VARCHAR(16) )");
   } finally {
     StatementUtils.attemptClose(stmt);
     ConnectionUtils.attemptClose(con);
   }
 }
Exemple #3
0
 static void doSomething(DataSource ds) throws SQLException {
   Connection con = null;
   Statement stmt = null;
   try {
     con = ds.getConnection();
     stmt = con.createStatement();
     int i =
         stmt.executeUpdate(
             "INSERT INTO TRSS_TABLE VALUES ('" + System.currentTimeMillis() + "')");
     if (i != 1) throw new SQLException("Insert failed somehow strange!");
   } finally {
     StatementUtils.attemptClose(stmt);
     ConnectionUtils.attemptClose(con);
   }
 }