Search in sources :

Example 1 with MSSQL

use of lucee.commons.io.res.type.datasource.core.MSSQL in project Lucee by lucee.

the class DatasourceResourceProvider method getCore.

private Core getCore(ConnectionData data) throws PageException {
    Core core = (Core) cores.get(data.datasourceName);
    if (core == null) {
        DatasourceConnection dc = getManager().getConnection(ThreadLocalPageContext.get(), data.getDatasourceName(), data.getUsername(), data.getPassword());
        try {
            dc.getConnection().setAutoCommit(false);
            dc.getConnection().setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
            if ("com.microsoft.jdbc.sqlserver.SQLServerDriver".equals(dc.getDatasource().getClassDefinition().getClassName()))
                core = new MSSQL(dc, data.getPrefix());
            else if ("com.microsoft.sqlserver.jdbc.SQLServerDriver".equals(dc.getDatasource().getClassDefinition().getClassName()))
                core = new MSSQL(dc, data.getPrefix());
            else if ("net.sourceforge.jtds.jdbc.Driver".equals(dc.getDatasource().getClassDefinition().getClassName()))
                core = new MSSQL(dc, data.getPrefix());
            else if ("org.gjt.mm.mysql.Driver".equals(dc.getDatasource().getClassDefinition().getClassName()))
                core = new MySQL(dc, data.getPrefix());
            else
                throw new ApplicationException("there is no DatasourceResource driver for this database [" + data.getPrefix() + "]");
            cores.put(data.datasourceName, core);
        } catch (SQLException e) {
            throw new DatabaseException(e, dc);
        } finally {
            release(dc);
        // manager.releaseConnection(CONNECTION_ID,dc);
        }
    }
    return core;
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) DatasourceConnection(lucee.runtime.db.DatasourceConnection) SQLException(java.sql.SQLException) MySQL(lucee.commons.io.res.type.datasource.core.MySQL) MSSQL(lucee.commons.io.res.type.datasource.core.MSSQL) DatabaseException(lucee.runtime.exp.DatabaseException) Core(lucee.commons.io.res.type.datasource.core.Core)

Aggregations

SQLException (java.sql.SQLException)1 Core (lucee.commons.io.res.type.datasource.core.Core)1 MSSQL (lucee.commons.io.res.type.datasource.core.MSSQL)1 MySQL (lucee.commons.io.res.type.datasource.core.MySQL)1 DatasourceConnection (lucee.runtime.db.DatasourceConnection)1 ApplicationException (lucee.runtime.exp.ApplicationException)1 DatabaseException (lucee.runtime.exp.DatabaseException)1