本文整理汇总了Java中org.quartz.utils.DBConnectionManager类的典型用法代码示例。如果您正苦于以下问题:Java DBConnectionManager类的具体用法?Java DBConnectionManager怎么用?Java DBConnectionManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DBConnectionManager类属于org.quartz.utils包,在下文中一共展示了DBConnectionManager类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: countTriggers
import org.quartz.utils.DBConnectionManager; //导入依赖的package包/类
@Override
public long countTriggers() {
try (Connection conn = DBConnectionManager.getInstance().getConnection(sqlProperties.getProperty(DATA_SOURCE));
Statement stmt = conn.createStatement()) {
ResultSet rs = stmt.executeQuery(buildCountTriggersQuery());
if (rs.next()) {
return rs.getInt(1);
}
return 0;
} catch (SQLException e) {
throw new TriggerRetrievalException("Couldn't count triggers for Scheduler channel", e);
}
}
开发者ID:motech,项目名称:motech,代码行数:17,代码来源:SchedulerChannelProvider.java
示例2: executeQuery
import org.quartz.utils.DBConnectionManager; //导入依赖的package包/类
private List<List<Object>> executeQuery(String query, List<String> columns) throws SQLException {
List<List<Object>> rows = new LinkedList<>();
try (Connection conn = DBConnectionManager.getInstance().getConnection(sqlProperties.getProperty(DATA_SOURCE));
Statement stmt = conn.createStatement()) {
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
List<Object> row = new LinkedList<>();
if (columns != null) {
for (String name : columns) {
row.add(rs.getObject(name));
}
}
rows.add(row);
}
}
return rows;
}
开发者ID:motech,项目名称:motech,代码行数:20,代码来源:MotechSchedulerDatabaseServiceImpl.java
示例3: QuartzProvider
import org.quartz.utils.DBConnectionManager; //导入依赖的package包/类
@Inject
public QuartzProvider(final Injector injector, final Config config,
@Named("org.quartz.jobs") final Map<JobDetail, Trigger> triggers) throws Exception {
requireNonNull(injector, "An injector is required.");
this.scheduler = new StdSchedulerFactory(properties(config)).getScheduler();
this.jobs = triggers.entrySet();
// override job factory
scheduler.setJobFactory((bundle, sch) -> {
JobDetail jobDetail = bundle.getJobDetail();
Class<?> jobClass = jobDetail.getJobClass();
return (Job) injector.getInstance(jobClass);
});
// hacky way of setting DS? quartz API sucks (it does too much or too little)
if (config.hasPath(DS)) {
String name = config.getString(DS);
// get a provider, bc ds wont be ready yet.
Provider<DataSource> ds = injector.getInstance(Key.get(DS_TYPE, Names.named(name)));
DBConnectionManager.getInstance()
.addConnectionProvider(name, new QuartzConnectionProvider(ds));
}
}
开发者ID:jooby-project,项目名称:jooby,代码行数:26,代码来源:QuartzProvider.java
示例4: shutdown
import org.quartz.utils.DBConnectionManager; //导入依赖的package包/类
@Override
public void shutdown() {
super.shutdown();
try {
DBConnectionManager.getInstance().shutdown(getNonManagedTXDataSource());
} catch (SQLException sqle) {
getLog().warn("Database connection shutdown unsuccessful.", sqle);
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:JobStoreCMT.java
示例5: shutdown
import org.quartz.utils.DBConnectionManager; //导入依赖的package包/类
public void shutdown() {
super.shutdown();
try {
DBConnectionManager.getInstance().shutdown(getNonManagedTXDataSource());
} catch (SQLException sqle) {
getLog().warn("Database connection shutdown unsuccessful.", sqle);
}
}
开发者ID:AsuraTeam,项目名称:asura,代码行数:11,代码来源:JobStoreCMT.java
示例6: getTriggers
import org.quartz.utils.DBConnectionManager; //导入依赖的package包/类
@Override
public List<TriggerEvent> getTriggers(int page, int pageSize) {
try (Connection conn = DBConnectionManager.getInstance().getConnection(sqlProperties.getProperty(DATA_SOURCE));
Statement stmt = conn.createStatement()) {
ResultSet rs = stmt.executeQuery(buildGetTriggersQuery(page, pageSize));
List<TriggerEvent> triggers = new ArrayList<>();
while (rs.next()) {
try (InputStream is = new ByteArrayInputStream(rs.getBytes(JOB_DATA));
ObjectInputStream ois = new ObjectInputStream(is)) {
JobDataMap dataMap = (JobDataMap) ois.readObject();
List<EventParameter> parameters = new ArrayList<>();
parameters.add(new EventParameter("scheduler.jobId", MotechSchedulerService.JOB_ID_KEY));
triggers.add(new TriggerEvent(
"Job: " + rs.getString(JOB_NAME),
rs.getString(JOB_NAME),
rs.getString(JOB_DESCRIPTION),
parameters,
dataMap.getString(SchedulerConstants.EVENT_TYPE_KEY_NAME)
));
}
}
return triggers;
} catch (SQLException|IOException|ClassNotFoundException e) {
throw new TriggerRetrievalException("Couldn't retrieve triggers for Scheduler channel", e);
}
}
开发者ID:motech,项目名称:motech,代码行数:33,代码来源:SchedulerChannelProvider.java
示例7: getTrigger
import org.quartz.utils.DBConnectionManager; //导入依赖的package包/类
@Override
public TriggerEvent getTrigger(TaskTriggerInformation info) {
try (Connection conn = DBConnectionManager.getInstance().getConnection(sqlProperties.getProperty(DATA_SOURCE));
Statement stmt = conn.createStatement()) {
ResultSet rs = stmt.executeQuery(buildGetTriggerQuery(info.getSubject()));
if (rs.next()) {
try (InputStream is = new ByteArrayInputStream(rs.getBytes(JOB_DATA));
ObjectInputStream ois = new ObjectInputStream(is)) {
JobDataMap dataMap = (JobDataMap) ois.readObject();
List<EventParameter> parameters = new ArrayList<>();
parameters.add(new EventParameter("scheduler.jobId", MotechSchedulerService.JOB_ID_KEY));
return new TriggerEvent(
"Job: " + rs.getString(JOB_NAME),
rs.getString(JOB_NAME),
rs.getString(JOB_DESCRIPTION),
parameters,
dataMap.getString(SchedulerConstants.EVENT_TYPE_KEY_NAME)
);
}
}
return null;
} catch (SQLException|IOException|ClassNotFoundException e) {
throw new TriggerRetrievalException("Couldn't retrieve triggers for Scheduler channel", e);
}
}
开发者ID:motech,项目名称:motech,代码行数:31,代码来源:SchedulerChannelProvider.java
示例8: executeCountQuery
import org.quartz.utils.DBConnectionManager; //导入依赖的package包/类
private int executeCountQuery(String query) throws SQLException {
int rowConut = 0;
try (Connection conn = DBConnectionManager.getInstance().getConnection(sqlProperties.getProperty(DATA_SOURCE));
Statement stmt = conn.createStatement()) {
ResultSet rs = stmt.executeQuery(query);
rs.next();
rowConut = rs.getInt(1);
}
return rowConut;
}
开发者ID:motech,项目名称:motech,代码行数:11,代码来源:MotechSchedulerDatabaseServiceImpl.java
示例9: initialize
import org.quartz.utils.DBConnectionManager; //导入依赖的package包/类
@Override
public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler)
throws SchedulerConfigException {
// Absolutely needs thread-bound DataSource to initialize.
this.dataSource = SchedulerFactoryBean.getConfigTimeDataSource();
if (this.dataSource == null) {
throw new SchedulerConfigException(
"No local DataSource found for configuration - " +
"'dataSource' property must be set on SchedulerFactoryBean");
}
// Configure transactional connection settings for Quartz.
setDataSource(TX_DATA_SOURCE_PREFIX + getInstanceName());
setDontSetAutoCommitFalse(true);
// Register transactional ConnectionProvider for Quartz.
DBConnectionManager.getInstance().addConnectionProvider(
TX_DATA_SOURCE_PREFIX + getInstanceName(),
new ConnectionProvider() {
@Override
public Connection getConnection() throws SQLException {
// Return a transactional Connection, if any.
return DataSourceUtils.doGetConnection(dataSource);
}
@Override
public void shutdown() {
// Do nothing - a Spring-managed DataSource has its own lifecycle.
}
/* Quartz 2.2 initialize method */
public void initialize() {
// Do nothing - a Spring-managed DataSource has its own lifecycle.
}
}
);
// Non-transactional DataSource is optional: fall back to default
// DataSource if not explicitly specified.
DataSource nonTxDataSource = SchedulerFactoryBean.getConfigTimeNonTransactionalDataSource();
final DataSource nonTxDataSourceToUse = (nonTxDataSource != null ? nonTxDataSource : this.dataSource);
// Configure non-transactional connection settings for Quartz.
setNonManagedTXDataSource(NON_TX_DATA_SOURCE_PREFIX + getInstanceName());
// Register non-transactional ConnectionProvider for Quartz.
DBConnectionManager.getInstance().addConnectionProvider(
NON_TX_DATA_SOURCE_PREFIX + getInstanceName(),
new ConnectionProvider() {
@Override
public Connection getConnection() throws SQLException {
// Always return a non-transactional Connection.
return nonTxDataSourceToUse.getConnection();
}
@Override
public void shutdown() {
// Do nothing - a Spring-managed DataSource has its own lifecycle.
}
/* Quartz 2.2 initialize method */
public void initialize() {
// Do nothing - a Spring-managed DataSource has its own lifecycle.
}
}
);
// No, if HSQL is the platform, we really don't want to use locks...
try {
String productName = JdbcUtils.extractDatabaseMetaData(this.dataSource, "getDatabaseProductName").toString();
productName = JdbcUtils.commonDatabaseName(productName);
if (productName != null && productName.toLowerCase().contains("hsql")) {
setUseDBLocks(false);
setLockHandler(new SimpleSemaphore());
}
}
catch (MetaDataAccessException ex) {
logWarnIfNonZero(1, "Could not detect database type. Assuming locks can be taken.");
}
super.initialize(loadHelper, signaler);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:81,代码来源:LocalDataSourceJobStore.java
示例10: initialize
import org.quartz.utils.DBConnectionManager; //导入依赖的package包/类
@Override
public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler)
throws SchedulerConfigException {
// Absolutely needs thread-bound DataSource to initialize.
this.dataSource = SchedulerFactoryBean.getConfigTimeDataSource();
if (this.dataSource == null) {
throw new SchedulerConfigException(
"No local DataSource found for configuration - " +
"'dataSource' property must be set on SchedulerFactoryBean");
}
// Configure transactional connection settings for Quartz.
setDataSource(TX_DATA_SOURCE_PREFIX + getInstanceName());
setDontSetAutoCommitFalse(true);
// Register transactional ConnectionProvider for Quartz.
DBConnectionManager.getInstance().addConnectionProvider(
TX_DATA_SOURCE_PREFIX + getInstanceName(),
new ConnectionProvider() {
public Connection getConnection() throws SQLException {
// Return a transactional Connection, if any.
return DataSourceUtils.doGetConnection(dataSource);
}
public void shutdown() {
// Do nothing - a Spring-managed DataSource has its own lifecycle.
}
/* Quartz 2.2 initialize method */
public void initialize() {
// Do nothing - a Spring-managed DataSource has its own lifecycle.
}
}
);
// Non-transactional DataSource is optional: fall back to default
// DataSource if not explicitly specified.
DataSource nonTxDataSource = SchedulerFactoryBean.getConfigTimeNonTransactionalDataSource();
final DataSource nonTxDataSourceToUse = (nonTxDataSource != null ? nonTxDataSource : this.dataSource);
// Configure non-transactional connection settings for Quartz.
setNonManagedTXDataSource(NON_TX_DATA_SOURCE_PREFIX + getInstanceName());
// Register non-transactional ConnectionProvider for Quartz.
DBConnectionManager.getInstance().addConnectionProvider(
NON_TX_DATA_SOURCE_PREFIX + getInstanceName(),
new ConnectionProvider() {
public Connection getConnection() throws SQLException {
// Always return a non-transactional Connection.
return nonTxDataSourceToUse.getConnection();
}
public void shutdown() {
// Do nothing - a Spring-managed DataSource has its own lifecycle.
}
/* Quartz 2.2 initialize method */
public void initialize() {
// Do nothing - a Spring-managed DataSource has its own lifecycle.
}
}
);
// No, if HSQL is the platform, we really don't want to use locks...
try {
String productName = JdbcUtils.extractDatabaseMetaData(this.dataSource, "getDatabaseProductName").toString();
productName = JdbcUtils.commonDatabaseName(productName);
if (productName != null && productName.toLowerCase().contains("hsql")) {
setUseDBLocks(false);
setLockHandler(new SimpleSemaphore());
}
}
catch (MetaDataAccessException ex) {
logWarnIfNonZero(1, "Could not detect database type. Assuming locks can be taken.");
}
super.initialize(loadHelper, signaler);
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:77,代码来源:LocalDataSourceJobStore.java
注:本文中的org.quartz.utils.DBConnectionManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论