Exemplo n.º 1
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);
   }
 }
Exemplo n.º 2
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);
   }
 }
Exemplo n.º 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);
   }
 }
Exemplo n.º 4
0
 static String toString(DataSource ds) {
   if (ds instanceof AbstractPoolBackedDataSource)
     return ((AbstractPoolBackedDataSource) ds).toString(true);
   else return ds.toString();
 }