Search in sources :

Example 26 with DataSource

use of lucee.runtime.db.DataSource in project Lucee by lucee.

the class ConfigImpl method getDataSource.

@Override
public DataSource getDataSource(String datasource) throws DatabaseException {
    DataSource ds = (datasource == null) ? null : (DataSource) datasources.get(datasource.toLowerCase());
    if (ds != null)
        return ds;
    // create error detail
    DatabaseException de = new DatabaseException("datasource [" + datasource + "] doesn't exist", null, null, null);
    de.setDetail(ExceptionUtil.createSoundexDetail(datasource, datasources.keySet().iterator(), "datasource names"));
    de.setAdditional(KeyConstants._Datasource, datasource);
    throw de;
}
Also used : DatabaseException(lucee.runtime.exp.DatabaseException) DataSource(lucee.runtime.db.DataSource)

Example 27 with DataSource

use of lucee.runtime.db.DataSource in project Lucee by lucee.

the class AppListenerUtil method toDataSources.

public static DataSource[] toDataSources(Config config, Object o, Log log) throws PageException {
    Struct sct = Caster.toStruct(o);
    Iterator<Entry<Key, Object>> it = sct.entryIterator();
    Entry<Key, Object> e;
    java.util.List<DataSource> dataSources = new ArrayList<DataSource>();
    while (it.hasNext()) {
        e = it.next();
        dataSources.add(toDataSource(config, e.getKey().getString().trim(), Caster.toStruct(e.getValue()), log));
    }
    return dataSources.toArray(new DataSource[dataSources.size()]);
}
Also used : Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) Key(lucee.runtime.type.Collection.Key) Struct(lucee.runtime.type.Struct) ApplicationDataSource(lucee.runtime.db.ApplicationDataSource) DataSource(lucee.runtime.db.DataSource)

Aggregations

DataSource (lucee.runtime.db.DataSource)27 PageException (lucee.runtime.exp.PageException)9 Struct (lucee.runtime.type.Struct)9 DatasourceConnection (lucee.runtime.db.DatasourceConnection)8 ApplicationException (lucee.runtime.exp.ApplicationException)8 ConfigImpl (lucee.runtime.config.ConfigImpl)7 StructImpl (lucee.runtime.type.StructImpl)7 SQLException (java.sql.SQLException)5 Map (java.util.Map)5 Log (lucee.commons.io.log.Log)5 Entry (java.util.Map.Entry)4 CacheConnection (lucee.runtime.cache.CacheConnection)4 ClassDefinition (lucee.runtime.db.ClassDefinition)4 DataSourceManager (lucee.runtime.db.DataSourceManager)4 DatasourceConnectionPool (lucee.runtime.db.DatasourceConnectionPool)4 ApplicationContext (lucee.runtime.listener.ApplicationContext)4 QueryImpl (lucee.runtime.type.QueryImpl)4 SQLExecutor (lucee.runtime.type.scope.storage.db.SQLExecutor)4 HashMap (java.util.HashMap)3 Iterator (java.util.Iterator)3