Browse Source

Merge branch 'feature/10.0' of http://cloud.finedevelop.com:2015/scm/ba/base-third into feature/10.0

10.0
daniel 7 years ago
parent
commit
2378b832dd
  1. 23
      fine-quartz/src/com/fr/third/v2/org/quartz/impl/jdbcjobstore/CUBRIDDelegate.java
  2. 51
      fine-quartz/src/com/fr/third/v2/org/quartz/utils/PoolingConnectionProvider.java

23
fine-quartz/src/com/fr/third/v2/org/quartz/impl/jdbcjobstore/CUBRIDDelegate.java

@ -17,9 +17,7 @@
package com.fr.third.v2.org.quartz.impl.jdbcjobstore;
import com.mchange.v2.c3p0.C3P0ProxyConnection;
import java.io.*;
import java.lang.reflect.Method;
import java.sql.*;
/**
@ -110,23 +108,8 @@ public class CUBRIDDelegate extends StdJDBCDelegate {
byteArray = baos.toByteArray();
}
//quartz 2.x uses c3p0, c3p0 doesn't support createBlob method as of 0.9.2
Connection conn = ps.getConnection();
if (conn instanceof C3P0ProxyConnection) {
try {
C3P0ProxyConnection c3p0Conn = (C3P0ProxyConnection) conn;
Method m = Connection.class.getMethod("createBlob", new Class[]{}); //will call createBlob method on the underlying connection
Object[] args = new Object[]{}; //arguments to be passed to the method. none in this case
Blob blob = (Blob) c3p0Conn.rawConnectionOperation(m, C3P0ProxyConnection.RAW_CONNECTION, args);
blob.setBytes(1, byteArray);
ps.setBlob(index, blob);
} catch (Exception ex) {
ex.printStackTrace();
}
} else {
Blob blob = ps.getConnection().createBlob();
blob.setBytes(1, byteArray);
ps.setBlob(index, blob);
}
Blob blob = ps.getConnection().createBlob();
blob.setBytes(1, byteArray);
ps.setBlob(index, blob);
}
}

51
fine-quartz/src/com/fr/third/v2/org/quartz/utils/PoolingConnectionProvider.java

@ -17,13 +17,12 @@
package com.fr.third.v2.org.quartz.utils;
import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;
import com.fr.third.alibaba.druid.pool.DruidDataSource;
import com.fr.third.v2.org.quartz.SchedulerException;
import com.mchange.v2.c3p0.ComboPooledDataSource;
/**
* <p>
@ -112,7 +111,7 @@ public class PoolingConnectionProvider implements ConnectionProvider {
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
private ComboPooledDataSource datasource;
private DruidDataSource datasource;
/*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -206,27 +205,35 @@ public class PoolingConnectionProvider implements ConnectionProvider {
}
datasource = new ComboPooledDataSource();
try {
datasource.setDriverClass(dbDriver);
} catch (PropertyVetoException e) {
throw new SchedulerException("Problem setting driver class name on datasource: " + e.getMessage(), e);
}
datasource.setJdbcUrl(dbURL);
datasource.setUser(dbUser);
datasource = new DruidDataSource();
datasource.setDriverClassName(dbDriver);
datasource.setUrl(dbURL);
datasource.setUsername(dbUser);
datasource.setPassword(dbPassword);
datasource.setMaxPoolSize(maxConnections);
datasource.setMinPoolSize(1);
datasource.setMaxIdleTime(maxIdleSeconds);
datasource.setMaxStatementsPerConnection(maxStatementsPerConnection);
datasource.setMaxActive(maxConnections);
datasource.setTimeBetweenEvictionRunsMillis(idleValidationSeconds * 1000);
if (maxIdleSeconds > 0) {
// 最小值30秒
maxIdleSeconds = maxIdleSeconds < 30 ? 30 : maxIdleSeconds;
datasource.setMaxEvictableIdleTimeMillis(maxIdleSeconds * 1000);
}
datasource.setMaxPoolPreparedStatementPerConnectionSize(maxStatementsPerConnection);
if (dbValidationQuery != null) {
datasource.setPreferredTestQuery(dbValidationQuery);
if(!validateOnCheckout)
datasource.setTestConnectionOnCheckin(true);
else
datasource.setTestConnectionOnCheckout(true);
datasource.setIdleConnectionTestPeriod(idleValidationSeconds);
datasource.setValidationQuery(dbValidationQuery);
if (!validateOnCheckout) {
datasource.setTestOnReturn(true);
datasource.setTestOnBorrow(false);
} else {
datasource.setTestOnReturn(false);
datasource.setTestOnBorrow(true);
}
datasource.setTestWhileIdle(true);
} else {
datasource.setTestOnReturn(false);
datasource.setTestOnBorrow(false);
datasource.setTestWhileIdle(false);
}
}
@ -238,7 +245,7 @@ public class PoolingConnectionProvider implements ConnectionProvider {
* subclass's constructor.
* </p>
*/
public ComboPooledDataSource getDataSource() {
public DruidDataSource getDataSource() {
return datasource;
}

Loading…
Cancel
Save