コード例 #1
0
 protected void tearDown() throws Exception {
   Statement stmt = createStatement();
   stmt.execute("DROP TABLE T0");
   stmt.close();
   commit();
   super.tearDown();
 }
コード例 #2
0
 /**
  * Creates a new database and keeps track of it to delete it when the clean up is invoked.
  *
  * <p>If the database already exists, a connection to the existing database is returned.
  *
  * @param dbName the database name
  * @param dbAttributes database attributes (i.e. encryption)
  * @param user user name
  * @param password user password
  * @return A connection to the database.
  * @throws SQLException if creating or connecting to the database fails
  */
 public Connection createDatabase(String dbName, String dbAttributes, String user, String password)
     throws SQLException {
   String userAttr = "";
   if (user != null) {
     userAttr = ";user="******";password="******";" + dbAttributes;
   }
   if (!userAttr.equals("")) {
     url += userAttr;
   }
   if (url.indexOf(ATTR_CREATE) == -1) {
     url += ATTR_CREATE;
   }
   Connection con = getConnection(url);
   if (con.getWarnings() != null) {
     // See if there are more than one warning.
     SQLWarning w = con.getWarnings();
     String warnings = w.getMessage();
     while ((w = w.getNextWarning()) != null) {
       warnings += " || " + w.getMessage();
     }
     BaseJDBCTestCase.fail("Warning(s) when creating database: " + warnings);
   }
   // Keep track of the database we just created, so that we can
   // delete it.
   DATABASES.add(dbName + userAttr);
   return con;
 }
コード例 #3
0
 protected void tearDown() throws Exception {
   if (clob != null) {
     clob.free();
     clob = null;
   }
   excludedMethodSet = null;
   super.tearDown();
 }
コード例 #4
0
 /**
  * Drops the specified database.
  *
  * <p>Note that the specified URL will be appended to a fixed JDBC protcol prefix.
  *
  * @param dbNameAndAttributes the database name and any attributes required to access the database
  *     (<em>excluding</em> the delete attribute, which is added by this method)
  * @throws SQLException if deleting the database fails
  */
 public void dropDatabase(String dbNameAndAttributes) throws SQLException {
   String url = JDBC_PREFIX + dbNameAndAttributes + ";drop=true";
   try {
     DriverManager.getConnection(url);
     BaseJDBCTestCase.fail("Dropping database should raise exception.");
   } catch (SQLException sqle) {
     if (sqle.getSQLState().equals("08006")) {
       // Database was deleted.
     } else if (sqle.getSQLState().equals("XJ004")) {
       // Database didn't exist. Already dropped?
     } else {
       BaseJDBCTestCase.assertSQLState(
           "Dropping database failed: (" + sqle.getSQLState() + ") " + sqle.getMessage(),
           "08006",
           sqle);
     }
   }
 }
コード例 #5
0
 protected void tearDown() throws Exception {
   getTestConfiguration().setVerbosity(savedVerbosity);
   super.tearDown();
 }