use of javax.sql.DataSource in project eweb4j-framework by laiweiwei.
the class DAOFactory method getDivPageDAO.
/**
* 创建DivPageDAOImpl实例
*
* @param dsName
* 数据库配置信息Bean的名字,默认下在eweb4j-dbInfo-config.xml文件中<name></name>
* 找到这个值
* @return
*/
public static DivPageDAO getDivPageDAO(String dsName) {
DataSource ds = DataSourceWrapCache.get(dsName);
DBInfoConfigBean dcb = DBInfoConfigBeanCache.get(dsName);
return new DivPageDAOImpl(ds, dcb.getDataBaseType());
}
use of javax.sql.DataSource in project eweb4j-framework by laiweiwei.
the class DAOFactory method getInsertDAO.
public static InsertDAO getInsertDAO() {
DataSource ds = DataSourceWrapCache.get();
DBInfoConfigBean dcb = DBInfoConfigBeanCache.get();
return new InsertDAOImpl(ds, dcb.getDataBaseType());
}
use of javax.sql.DataSource in project eweb4j-framework by laiweiwei.
the class DAOImpl method execute.
public Number execute() {
Number rs = 0;
String sql = this.sql.toString().replace("${_where_}", this.condition.toString()).replace("'?'", "?");
DataSource ds = DataSourceWrapCache.get(dsName);
try {
if (args != null && args.size() > 0) {
rs = JdbcUtil.updateWithArgs(ds.getConnection(), sql, args.toArray(new Object[] {}));
} else {
rs = JdbcUtil.update(ds.getConnection(), sql);
}
} catch (SQLException e) {
log.error("sql-->" + sql, e);
throw new DAOException(sql + " execute exception", e);
}
//this.clear();
return rs;
}
use of javax.sql.DataSource in project head by mifos.
the class ApplicationInitializer method initJNDIforPentaho.
private void initJNDIforPentaho(ApplicationContext applicationContext) {
try {
InitialContext ic = new InitialContext();
//check if ds is already bound
boolean dataSourceBound = true;
boolean dataSourceBoundDw = true;
try {
DataSource datasource = (DataSource) ic.lookup("jdbc/SourceDB");
if (datasource != null) {
dataSourceBound = true;
}
} catch (Exception ex) {
dataSourceBound = false;
}
try {
DataSource datasourcedw = (DataSource) ic.lookup("jdbc/DestinationDB");
if (datasourcedw != null) {
dataSourceBoundDw = true;
}
} catch (Exception ex) {
dataSourceBoundDw = false;
}
if (!dataSourceBound) {
Object dataSource = applicationContext.getBean("dataSource");
try {
ic.createSubcontext("jdbc");
} catch (NameAlreadyBoundException ex) {
logger.info("Subcontext jdbc was already bound");
}
ic.bind("jdbc/SourceDB", dataSource);
logger.info("Bound datasource to jdbc/SourceDB");
} else {
logger.info("jdbc/SourceDB is already bound");
}
if (!dataSourceBoundDw) {
Object dataSourcedw = applicationContext.getBean("dataSourcePentahoDW");
try {
ic.createSubcontext("jdbc");
} catch (NameAlreadyBoundException ex) {
logger.info("Subcontext jdbc was already bound");
}
ic.bind("jdbc/DestinationDB", dataSourcedw);
logger.info("Bound datasource to jdbc/DestinationDB");
} else {
logger.info("jdbc/DestinationDB is already bound");
}
} catch (Exception ex) {
logger.error("Unable to bind dataSource to JNDI");
}
}
use of javax.sql.DataSource in project databus by linkedin.
the class OracleEventProducerFactory method buildEventProducer.
public EventProducer buildEventProducer(PhysicalSourceStaticConfig physicalSourceConfig, SchemaRegistryService schemaRegistryService, DbusEventBufferAppendable dbusEventBuffer, MBeanServer mbeanServer, DbusEventsStatisticsCollector dbusEventsStatisticsCollector, MaxSCNReaderWriter _maxScnReaderWriter) throws DatabusException, EventCreationException, UnsupportedKeyException, SQLException, InvalidConfigException {
// Make sure the URI from the configuration file identifies an Oracle JDBC source.
String uri = physicalSourceConfig.getUri();
if (!uri.startsWith("jdbc:oracle")) {
throw new InvalidConfigException("Invalid source URI (" + physicalSourceConfig.getUri() + "). Only jdbc:oracle: URIs are supported.");
}
// Parse each one of the logical sources
List<OracleTriggerMonitoredSourceInfo> sources = new ArrayList<OracleTriggerMonitoredSourceInfo>();
for (LogicalSourceStaticConfig sourceConfig : physicalSourceConfig.getSources()) {
OracleTriggerMonitoredSourceInfo source = buildOracleMonitoredSourceInfo(sourceConfig, physicalSourceConfig, schemaRegistryService);
sources.add(source);
}
DataSource ds = null;
try {
ds = OracleJarUtils.createOracleDataSource(uri);
} catch (Exception e) {
String errMsg = "Oracle URI likely not supported. Trouble creating OracleDataSource";
_log.error(errMsg);
throw new InvalidConfigException(errMsg + e.getMessage());
}
// Create the event producer
EventProducer eventProducer = new OracleEventProducer(sources, ds, dbusEventBuffer, true, dbusEventsStatisticsCollector, _maxScnReaderWriter, physicalSourceConfig, ManagementFactory.getPlatformMBeanServer());
_log.info("Created OracleEventProducer for config: " + physicalSourceConfig + " with slowSourceQueryThreshold = " + physicalSourceConfig.getSlowSourceQueryThreshold());
return eventProducer;
}
Aggregations