Search in sources :

Example 1 with JdbcPooledConnectionSource

use of com.j256.ormlite.jdbc.JdbcPooledConnectionSource in project IPK-BrAPI-Validator by plantbreeding.

the class AppServletContextListener method createDatabaseConnection.

private static void createDatabaseConnection(ServletContext servletContext) {
    String path = Config.get("dbpath");
    String databaseUrl = path;
    ConnectionSource connectionSource;
    try {
        connectionSource = new JdbcPooledConnectionSource(databaseUrl);
        ((JdbcPooledConnectionSource) connectionSource).setUsername(Config.get("dbuser"));
        ((JdbcPooledConnectionSource) connectionSource).setPassword(Config.get("dbpass"));
        if (connectionSource.getDatabaseType().getClass().equals(com.j256.ormlite.db.OracleDatabaseType.class)) {
            Cache.addToCache("dbType", "oracle");
        } else {
            Cache.addToCache("dbType", "other");
        }
        DataSourceManager.setConnectionSource(connectionSource);
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
Also used : SQLException(java.sql.SQLException) JdbcPooledConnectionSource(com.j256.ormlite.jdbc.JdbcPooledConnectionSource) ConnectionSource(com.j256.ormlite.support.ConnectionSource) JdbcPooledConnectionSource(com.j256.ormlite.jdbc.JdbcPooledConnectionSource)

Aggregations

JdbcPooledConnectionSource (com.j256.ormlite.jdbc.JdbcPooledConnectionSource)1 ConnectionSource (com.j256.ormlite.support.ConnectionSource)1 SQLException (java.sql.SQLException)1