use of lucee.runtime.db.DataSourceManager in project Lucee by lucee.
the class ColumnInfo method doEndTag.
@Override
public int doEndTag() throws PageException {
Object ds = DBInfo.getDatasource(pageContext, datasource);
DataSourceManager manager = pageContext.getDataSourceManager();
DatasourceConnection dc = ds instanceof DataSource ? manager.getConnection(pageContext, (DataSource) ds, username, password) : manager.getConnection(pageContext, Caster.toString(ds), username, password);
try {
Struct meta = null;
try {
meta = getMeta(dc, tablequalifier, tableowner, tablename);
} catch (SQLException se) {
meta = new StructImpl();
}
SQL sql = createSQL(meta);
if (sql != null) {
lucee.runtime.type.Query query = new QueryImpl(pageContext, dc, sql, -1, -1, null, "query");
if (pageContext.getConfig().debug()) {
String dsn = ds instanceof DataSource ? ((DataSource) ds).getName() : Caster.toString(ds);
boolean logdb = ((ConfigImpl) pageContext.getConfig()).hasDebugOptions(ConfigImpl.DEBUG_DATABASE);
if (logdb) {
boolean debugUsage = DebuggerImpl.debugQueryUsage(pageContext, query);
pageContext.getDebugger().addQuery(debugUsage ? query : null, dsn, "", sql, query.getRecordcount(), pageContext.getCurrentPageSource(), query.getExecutionTime());
}
}
// log
Log log = pageContext.getConfig().getLog("datasource");
if (log.getLogLevel() >= Log.LEVEL_INFO) {
log.info("insert tag", "executed [" + sql.toString().trim() + "] in " + DecimalFormat.call(pageContext, query.getExecutionTime() / 1000000D) + " ms");
}
}
return EVAL_PAGE;
} catch (PageException pe) {
pageContext.getConfig().getLog("datasource").error("insert tag", pe);
throw pe;
} finally {
manager.releaseConnection(pageContext, dc);
}
}
use of lucee.runtime.db.DataSourceManager in project Lucee by lucee.
the class Transaction method doCatch.
@Override
public void doCatch(Throwable t) throws Throwable {
ExceptionUtil.rethrowIfNecessary(t);
if (innerTag || ignore)
throw t;
DataSourceManager manager = pageContext.getDataSourceManager();
try {
manager.rollback();
} catch (DatabaseException e) {
// print.printST(e);
}
throw t;
}
use of lucee.runtime.db.DataSourceManager in project Lucee by lucee.
the class Admin method _doVerifyDatasource.
private void _doVerifyDatasource(String name, String username, String password) throws PageException {
DataSourceManager manager = pageContext.getDataSourceManager();
manager.releaseConnection(pageContext, manager.getConnection(pageContext, name, username, password));
}
use of lucee.runtime.db.DataSourceManager in project Lucee by lucee.
the class DataSourceServiceImpl method verifyDatasource.
@Override
public boolean verifyDatasource(String name) throws SQLException, SecurityException {
checkReadAccess();
lucee.runtime.db.DataSource d = _getDatasource(name);
PageContext pc = pc();
DataSourceManager manager = pc.getDataSourceManager();
try {
manager.releaseConnection(pc, manager.getConnection(pc, name, d.getUsername(), d.getPassword()));
return true;
} catch (PageException e) {
return false;
}
}
Aggregations