Search in sources :

Example 36 with DatabaseException

use of lucee.runtime.exp.DatabaseException in project Lucee by lucee.

the class DatasourceResourceProvider method getDatasourceConnection.

private DatasourceConnection getDatasourceConnection(ConnectionData data, boolean autoCommit) throws PageException {
    DatasourceConnection dc = getManager().getConnection(ThreadLocalPageContext.get(), data.getDatasourceName(), data.getUsername(), data.getPassword());
    try {
        dc.getConnection().setAutoCommit(autoCommit);
        dc.getConnection().setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
    } catch (SQLException e) {
        throw new DatabaseException(e, dc);
    }
    return dc;
}
Also used : DatasourceConnection(lucee.runtime.db.DatasourceConnection) SQLException(java.sql.SQLException) DatabaseException(lucee.runtime.exp.DatabaseException)

Example 37 with DatabaseException

use of lucee.runtime.exp.DatabaseException in project Lucee by lucee.

the class DatasourceResourceProvider method _getAttr.

private Attr _getAttr(ConnectionData data, int fullPathHash, String path, String name) throws PageException {
    if (!StringUtil.isEmpty(data.getDatasourceName())) {
        DatasourceConnection dc = null;
        try {
            dc = getDatasourceConnection(data);
            Attr attr = getCore(data).getAttr(dc, data.getPrefix(), fullPathHash, path, name);
            if (attr != null)
                return putToCache(data, path, name, attr);
        } catch (SQLException e) {
            throw new DatabaseException(e, dc);
        } finally {
            getManager().releaseConnection(ThreadLocalPageContext.get(), dc);
        }
    }
    return putToCache(data, path, name, Attr.notExists(name, path));
}
Also used : DatasourceConnection(lucee.runtime.db.DatasourceConnection) SQLException(java.sql.SQLException) DatabaseException(lucee.runtime.exp.DatabaseException)

Aggregations

DatabaseException (lucee.runtime.exp.DatabaseException)37 SQLException (java.sql.SQLException)16 PageException (lucee.runtime.exp.PageException)9 QueryImpl (lucee.runtime.type.QueryImpl)9 DatasourceConnection (lucee.runtime.db.DatasourceConnection)8 ORMDatasourceConnection (lucee.runtime.orm.ORMDatasourceConnection)6 Key (lucee.runtime.type.Collection.Key)6 Pair (lucee.commons.lang.Pair)4 ConfigImpl (lucee.runtime.config.ConfigImpl)4 SQLImpl (lucee.runtime.db.SQLImpl)4 ApplicationException (lucee.runtime.exp.ApplicationException)4 Connection (java.sql.Connection)3 ArrayList (java.util.ArrayList)3 Log (lucee.commons.io.log.Log)3 SQLItemImpl (lucee.runtime.db.SQLItemImpl)3 DeprecatedException (lucee.runtime.exp.DeprecatedException)3 PageRuntimeException (lucee.runtime.exp.PageRuntimeException)3 Collection (lucee.runtime.type.Collection)3 Query (lucee.runtime.type.Query)3 QueryColumn (lucee.runtime.type.QueryColumn)3