Search in sources :

Example 1 with ManualThreadDataSourceHandler

use of org.dbflute.jdbc.ManualThreadDataSourceHandler in project dbflute-core by dbflute.

the class TnAbstractBasicSqlHandler method getConnection.

// ===================================================================================
// JDBC Handling
// =============
// -----------------------------------------------------
// Connection
// ----------
/**
 * Get the database connection from data source. <br>
 * getting connection for SQL executions is only here. <br>
 * (for meta data is at TnBeanMetaDataFactoryImpl)
 * @return The new-created or inherited instance of connection. (NotNull)
 */
protected Connection getConnection() {
    try {
        final ManualThreadDataSourceHandler handler = getManualThreadDataSourceHandler();
        if (handler != null) {
            return handler.getConnection(_dataSource);
        }
        final Connection conn = _dataSource.getConnection();
        return conn;
    } catch (SQLException e) {
        final SQLExceptionResource resource = createSQLExceptionResource();
        resource.setNotice("Failed to get database connection.");
        handleSQLException(e, resource);
        // unreachable
        return null;
    }
}
Also used : SQLException(java.sql.SQLException) SQLExceptionResource(org.dbflute.bhv.exception.SQLExceptionResource) Connection(java.sql.Connection) ManualThreadDataSourceHandler(org.dbflute.jdbc.ManualThreadDataSourceHandler)

Aggregations

Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 SQLExceptionResource (org.dbflute.bhv.exception.SQLExceptionResource)1 ManualThreadDataSourceHandler (org.dbflute.jdbc.ManualThreadDataSourceHandler)1