Search in sources :

Example 6 with FBSQLException

use of org.firebirdsql.jdbc.FBSQLException in project jaybird by FirebirdSQL.

the class FBConnectionPoolDataSource method initialize.

private void initialize() throws SQLException {
    synchronized (lock) {
        if (internalDs != null) {
            return;
        }
        try {
            GDSType gdsType = GDSType.getType(getType());
            if (gdsType == null) {
                gdsType = GDSFactory.getDefaultGDSType();
            }
            FBManagedConnectionFactory mcf = new FBManagedConnectionFactory(gdsType, getConnectionProperties());
            internalDs = (FBDataSource) mcf.createConnectionFactory();
            internalDs.setLogWriter(getLogWriter());
        } catch (ResourceException e) {
            throw new FBSQLException(e);
        }
    }
}
Also used : FBManagedConnectionFactory(org.firebirdsql.jca.FBManagedConnectionFactory) ResourceException(javax.resource.ResourceException) FBSQLException(org.firebirdsql.jdbc.FBSQLException) GDSType(org.firebirdsql.gds.impl.GDSType)

Example 7 with FBSQLException

use of org.firebirdsql.jdbc.FBSQLException in project jaybird by FirebirdSQL.

the class FBPooledConnection method getConnection.

@Override
public synchronized Connection getConnection() throws SQLException {
    if (connection == null) {
        FBSQLException ex = new FBSQLException("The PooledConnection has been closed", SQLStateConstants.SQL_STATE_CONNECTION_CLOSED);
        fireFatalConnectionError(ex);
        throw ex;
    }
    try {
        if (handler != null) {
            handler.close();
        }
        resetConnection(connection);
    } catch (SQLException ex) {
        fireFatalConnectionError(ex);
        throw ex;
    }
    handler = createConnectionHandler(connection);
    return handler.getProxy();
}
Also used : SQLException(java.sql.SQLException) FBSQLException(org.firebirdsql.jdbc.FBSQLException) FBSQLException(org.firebirdsql.jdbc.FBSQLException)

Aggregations

FBSQLException (org.firebirdsql.jdbc.FBSQLException)7 SQLException (java.sql.SQLException)4 Connection (java.sql.Connection)3 Expectations (org.jmock.Expectations)3 Test (org.junit.Test)3 Statement (java.sql.Statement)2 ResourceException (javax.resource.ResourceException)2 GDSType (org.firebirdsql.gds.impl.GDSType)2 FBManagedConnectionFactory (org.firebirdsql.jca.FBManagedConnectionFactory)2 FirebirdConnection (org.firebirdsql.jdbc.FirebirdConnection)2 Sequence (org.jmock.Sequence)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ConnectionEventListener (javax.sql.ConnectionEventListener)1