Exemplo n.º 1
0
 public void stop() throws PersistenceException {
   if (config.dropOnExit()) {
     Connection conn = null;
     try {
       conn = connectionFactory.getConnection();
       dropTable(conn);
     } finally {
       connectionFactory.releaseConnection(conn);
     }
   }
 }
Exemplo n.º 2
0
 private DatabaseType getDialect() {
   if (databaseType == null) {
     // need to guess from the database type!
     Connection connection = null;
     try {
       connection = connectionFactory.getConnection();
       String dbProduct = connection.getMetaData().getDatabaseProductName();
       databaseType = guessDialect(dbProduct);
     } catch (Exception e) {
       log.debug("Unable to guess dialect from JDBC metadata.", e);
     } finally {
       connectionFactory.releaseConnection(connection);
     }
     if (databaseType == null) {
       log.debug(
           "Unable to detect database dialect using connection metadata.  Attempting to guess on driver name.");
       try {
         connection = connectionFactory.getConnection();
         String dbProduct = connectionFactory.getConnection().getMetaData().getDriverName();
         databaseType = guessDialect(dbProduct);
       } catch (Exception e) {
         log.debug("Unable to guess database dialect from JDBC driver name.", e);
       } finally {
         connectionFactory.releaseConnection(connection);
       }
     }
     if (databaseType == null) {
       throw new CacheConfigurationException(
           "Unable to detect database dialect from JDBC driver name or connection metadata.  Please provide this manually using the 'dialect' property in your configuration.  Supported database dialect strings are "
               + Arrays.toString(DatabaseType.values()));
     } else {
       log.debugf(
           "Guessing database dialect as '%s'.  If this is incorrect, please specify the correct dialect using the 'dialect' attribute in your configuration.  Supported database dialect strings are %s",
           databaseType, Arrays.toString(DatabaseType.values()));
     }
   }
   return databaseType;
 }