optimized for oracle 10

This commit is contained in:
wenshao
2012-01-06 10:15:46 +08:00
parent 00f0168dc0
commit cb7d672b13
16 changed files with 322 additions and 290 deletions
@@ -0,0 +1,70 @@
package com.alibaba.druid;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import junit.framework.Assert;
import junit.framework.TestCase;
import com.alibaba.druid.pool.DruidDataSource;
public class TestOracle extends TestCase {
private String jdbcUrl;
private String user;
private String password;
private String driverClass;
private String SQL;
protected void setUp() throws Exception {
// jdbcUrl = "jdbc:oracle:thin:@10.20.149.85:1521:ocnauto";
// user = "alibaba";
// password = "ccbuauto";
// SQL = "SELECT * FROM WP_ORDERS WHERE ID = ?";
jdbcUrl = "jdbc:oracle:thin:@10.20.149.81:1521:ointest3";
user = "alibaba";
password = "deYcR7facWSJtCuDpm2r";
SQL = "SELECT * FROM AV_INFO WHERE ID = ?";
driverClass = "oracle.jdbc.driver.OracleDriver";
}
public void test_o() throws Exception {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName(driverClass);
dataSource.setUrl(jdbcUrl);
dataSource.setUsername(user);
dataSource.setPassword(password);
dataSource.setPoolPreparedStatements(true);
dataSource.setMaxOpenPreparedStatements(50);
dataSource.setUseOracleImplicitCache(true);
// dataSource.setConnectionProperties("oracle.jdbc.FreeMemoryOnEnterImplicitCache=true");
for (int i = 1; i <= 1; ++i) {
Connection conn = dataSource.getConnection();
int rowNum = i + 1; // (i % 50) + 1;
String sql = SQL + " AND ROWNUM <= " + rowNum;
PreparedStatement stmt = conn.prepareStatement(sql);
stmt.setInt(1, 61);
ResultSet rs = stmt.executeQuery();
int rowCount = 0;
while (rs.next()) {
rowCount++;
}
Assert.assertEquals(true, rowCount > 0);
// Assert.isTrue(!rs.isClosed());
rs.close();
// Assert.isTrue(!stmt.isClosed());
stmt.close();
conn.close();
}
dataSource.close();
}
}
@@ -0,0 +1,105 @@
package com.alibaba.druid.bvt.bug;
import java.beans.PropertyVetoException;
import java.sql.SQLException;
import junit.framework.Assert;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.impl.NutDao;
import org.nutz.trans.Atom;
import org.nutz.trans.Trans;
import com.alibaba.druid.pool.DruidDataSource;
import com.mchange.v2.c3p0.ComboPooledDataSource;
public class TestRollBack {
static ComboPooledDataSource c3p0;
static DruidDataSource druid;
static Dao dao_c3p0;
static Dao dao_druid;
static String url = "jdbc:oracle:thin:@10.20.149.85:1521:ocnauto";
static String user = "alibaba";
static String password = "ccbuauto";
// jdbcUrl = "jdbc:oracle:thin:@10.20.149.85:1521:ocnauto";
// user = "alibaba";
// password = "ccbuauto";
@BeforeClass
public static void init() throws PropertyVetoException, SQLException {
c3p0 = new ComboPooledDataSource();
c3p0.setDriverClass("oracle.jdbc.driver.OracleDriver");
c3p0.setJdbcUrl(url);
c3p0.setUser(user);
c3p0.setPassword(password);
druid = new DruidDataSource();
druid.setUrl(url);
druid.setUsername(user);
druid.setPassword(password);
druid.setFilters("stat,trace,encoding");
druid.setDefaultAutoCommit(false);
dao_c3p0 = new NutDao(c3p0);
dao_druid = new NutDao(druid);
if (!dao_c3p0.exists("msg")) {
dao_c3p0.execute(Sqls.create("create table msg(message varchar2(5))")); // 字段长度5
}
}
@AfterClass
public static void destory() {
c3p0.close();
druid.close();
}
@Before
public void before() {
// 清空所有数据
dao_c3p0.clear("msg");
}
@Test
public void test_c3p0() {
try {
// 将两条插入语句包裹在一个事务内执行,第一条可以正常插入,第二条超过字段长度,会抛异常,事务会回滚
Trans.exec(new Atom() {
@Override
public void run() {
dao_c3p0.insert("msg", Chain.make("message", "abc"));
dao_c3p0.insert("msg", Chain.make("message", "1234567"));
}
});
} catch (Exception e) {
}
// abc也跟着回滚了
Assert.assertNull(dao_c3p0.fetch("msg", Cnd.where("message", "=", "abc")));
}
@Test
public void test_druid() {
try {
Trans.exec(new Atom() {
@Override
public void run() {
dao_druid.insert("msg", Chain.make("message", "abc"));
dao_druid.insert("msg", Chain.make("message", "1234567"));
}
});
} catch (Exception e) {
e.printStackTrace(); // 把这里的异常打印出来
}
// abc插了进去,没有回滚
Assert.assertNotNull(dao_druid.fetch("msg", Cnd.where("message", "=", "abc")));
}
}
@@ -11,17 +11,11 @@ import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.EnumSet;
import java.util.Properties;
import java.util.TimeZone;
import oracle.jdbc.OracleOCIFailover;
import oracle.jdbc.OracleSavepoint;
import oracle.jdbc.aq.AQDequeueOptions;
import oracle.jdbc.aq.AQEnqueueOptions;
import oracle.jdbc.aq.AQMessage;
import oracle.jdbc.aq.AQNotificationRegistration;
import oracle.jdbc.dcn.DatabaseChangeRegistration;
import oracle.jdbc.internal.OracleConnection;
import oracle.jdbc.pool.OracleConnectionCacheCallback;
import oracle.sql.ARRAY;
@@ -50,872 +44,672 @@ public class OracleMockConnection extends MockConnection implements oracle.jdbc.
public OracleMockConnection(MockDriver driver, String url, Properties connectProperties){
super(driver, url, connectProperties);
String val = (String) connectProperties.get("defaultRowPrefetch");
if (val != null) {
defaultRowPrefetch = Integer.parseInt(val);
}
}
@Override
public Connection _getPC() {
// TODO Auto-generated method stub
return null;
}
@Override
public void abort() throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void applyConnectionAttributes(Properties arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void archive(int arg0, int arg1, String arg2) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void cancel() throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void clearAllApplicationContext(String arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void close(Properties arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void close(int arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void commit(EnumSet<CommitOption> arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public ARRAY createARRAY(String arg0, Object arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public BINARY_DOUBLE createBINARY_DOUBLE(double arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public BINARY_FLOAT createBINARY_FLOAT(float arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public DATE createDATE(Date arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public DATE createDATE(Time arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public DATE createDATE(Timestamp arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public DATE createDATE(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public DATE createDATE(Date arg0, Calendar arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public DATE createDATE(Time arg0, Calendar arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public DATE createDATE(Timestamp arg0, Calendar arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public INTERVALDS createINTERVALDS(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public INTERVALYM createINTERVALYM(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public NUMBER createNUMBER(boolean arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public NUMBER createNUMBER(byte arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public NUMBER createNUMBER(short arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public NUMBER createNUMBER(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public NUMBER createNUMBER(long arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public NUMBER createNUMBER(float arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public NUMBER createNUMBER(double arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public NUMBER createNUMBER(BigDecimal arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public NUMBER createNUMBER(BigInteger arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public NUMBER createNUMBER(String arg0, int arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Array createOracleArray(String arg0, Object arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TIMESTAMP createTIMESTAMP(Date arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TIMESTAMP createTIMESTAMP(DATE arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TIMESTAMP createTIMESTAMP(Time arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TIMESTAMP createTIMESTAMP(Timestamp arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TIMESTAMP createTIMESTAMP(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TIMESTAMPLTZ createTIMESTAMPLTZ(Date arg0, Calendar arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TIMESTAMPLTZ createTIMESTAMPLTZ(Time arg0, Calendar arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TIMESTAMPLTZ createTIMESTAMPLTZ(Timestamp arg0, Calendar arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TIMESTAMPLTZ createTIMESTAMPLTZ(String arg0, Calendar arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TIMESTAMPLTZ createTIMESTAMPLTZ(DATE arg0, Calendar arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TIMESTAMPTZ createTIMESTAMPTZ(Date arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TIMESTAMPTZ createTIMESTAMPTZ(Time arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TIMESTAMPTZ createTIMESTAMPTZ(Timestamp arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TIMESTAMPTZ createTIMESTAMPTZ(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TIMESTAMPTZ createTIMESTAMPTZ(DATE arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TIMESTAMPTZ createTIMESTAMPTZ(Date arg0, Calendar arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TIMESTAMPTZ createTIMESTAMPTZ(Time arg0, Calendar arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TIMESTAMPTZ createTIMESTAMPTZ(Timestamp arg0, Calendar arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TIMESTAMPTZ createTIMESTAMPTZ(String arg0, Calendar arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public AQMessage dequeue(String arg0, AQDequeueOptions arg1, byte[] arg2) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public AQMessage dequeue(String arg0, AQDequeueOptions arg1, String arg2) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public void enqueue(String arg0, AQEnqueueOptions arg1, AQMessage arg2) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public TypeDescriptor[] getAllTypeDescriptorsInCurrentSchema() throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public String getAuthenticationAdaptorName() throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean getAutoClose() throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
public CallableStatement getCallWithKey(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Properties getConnectionAttributes() throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public int getConnectionReleasePriority() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean getCreateStatementAsRefCursor() {
// TODO Auto-generated method stub
return false;
}
@Override
public String getCurrentSchema() throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public String getDataIntegrityAlgorithmName() throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public DatabaseChangeRegistration getDatabaseChangeRegistration(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public int getDefaultExecuteBatch() {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getDefaultRowPrefetch() {
return defaultRowPrefetch;
}
@Override
public TimeZone getDefaultTimeZone() throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Object getDescriptor(String arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public String getEncryptionAlgorithmName() throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public short getEndToEndECIDSequenceNumber() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public String[] getEndToEndMetrics() throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean getExplicitCachingEnabled() throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean getImplicitCachingEnabled() throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean getIncludeSynonyms() {
// TODO Auto-generated method stub
return false;
}
@Override
public Object getJavaObject(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Properties getProperties() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean getRemarksReporting() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean getRestrictGetTables() {
// TODO Auto-generated method stub
return false;
}
@Override
public String getSQLType(Object arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public String getSessionTimeZone() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getSessionTimeZoneOffset() throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public int getStatementCacheSize() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public PreparedStatement getStatementWithKey(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public int getStmtCacheSize() {
// TODO Auto-generated method stub
return 0;
}
@Override
public short getStructAttrCsId() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public TypeDescriptor[] getTypeDescriptorsFromList(String[][] arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public TypeDescriptor[] getTypeDescriptorsFromListInCurrentSchema(String[] arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Properties getUnMatchedConnectionAttributes() throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public String getUserName() throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean getUsingXAFlag() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean getXAErrorFlag() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isLogicalConnection() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isProxySession() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isUsable() {
// TODO Auto-generated method stub
return false;
}
@Override
public void openProxySession(int arg0, Properties arg1) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void oracleReleaseSavepoint(OracleSavepoint arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void oracleRollback(OracleSavepoint arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public OracleSavepoint oracleSetSavepoint() throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public OracleSavepoint oracleSetSavepoint(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public OracleConnection physicalConnectionWithin() {
// TODO Auto-generated method stub
return null;
}
@Override
public int pingDatabase() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public int pingDatabase(int arg0) throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public CallableStatement prepareCallWithKey(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public PreparedStatement prepareStatementWithKey(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public void purgeExplicitCache() throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void purgeImplicitCache() throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void putDescriptor(String arg0, Object arg1) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public AQNotificationRegistration[] registerAQNotification(String[] arg0, Properties[] arg1, Properties arg2)
throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public void registerConnectionCacheCallback(OracleConnectionCacheCallback arg0, Object arg1, int arg2)
throws SQLException {
// TODO Auto-generated method stub
}
@Override
public DatabaseChangeRegistration registerDatabaseChangeNotification(Properties arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public void registerSQLType(String arg0, Class arg1) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void registerSQLType(String arg0, String arg1) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void registerTAFCallback(OracleOCIFailover arg0, Object arg1) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setApplicationContext(String arg0, String arg1, String arg2) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setAutoClose(boolean arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setConnectionReleasePriority(int arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setCreateStatementAsRefCursor(boolean arg0) {
// TODO Auto-generated method stub
}
@Override
public void setDefaultExecuteBatch(int arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setDefaultRowPrefetch(int defaultRowPrefetch) throws SQLException {
this.defaultRowPrefetch = defaultRowPrefetch;
}
@Override
public void setDefaultTimeZone(TimeZone arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setEndToEndMetrics(String[] arg0, short arg1) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setExplicitCachingEnabled(boolean arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setImplicitCachingEnabled(boolean arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setIncludeSynonyms(boolean arg0) {
// TODO Auto-generated method stub
}
@Override
public void setPlsqlWarnings(String arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setRemarksReporting(boolean arg0) {
// TODO Auto-generated method stub
}
@Override
public void setRestrictGetTables(boolean arg0) {
// TODO Auto-generated method stub
}
@Override
public void setSessionTimeZone(String arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setStatementCacheSize(int arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setStmtCacheSize(int arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setStmtCacheSize(int arg0, boolean arg1) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setUsingXAFlag(boolean arg0) {
// TODO Auto-generated method stub
}
@Override
public void setWrapper(oracle.jdbc.OracleConnection arg0) {
// TODO Auto-generated method stub
}
@Override
public void setXAErrorFlag(boolean arg0) {
// TODO Auto-generated method stub
}
@Override
public void shutdown(DatabaseShutdownMode arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void startup(DatabaseStartupMode arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void startup(String arg0, int arg1) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void unregisterAQNotification(AQNotificationRegistration arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void unregisterDatabaseChangeNotification(DatabaseChangeRegistration arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void unregisterDatabaseChangeNotification(int arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void unregisterDatabaseChangeNotification(long arg0, String arg1) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void unregisterDatabaseChangeNotification(int arg0, String arg1, int arg2) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public oracle.jdbc.OracleConnection unwrap() {
// TODO Auto-generated method stub
return null;
}
@Override
public PreparedStatement prepareStatement(String sql) throws SQLException {
if (isClosed()) {
throw new MockConnectionClosedException();
@@ -923,4 +717,10 @@ public class OracleMockConnection extends MockConnection implements oracle.jdbc.
return new OracleMockPreparedStatement(this, sql);
}
@Override
public void shutdown(int arg0) throws SQLException {
// TODO Auto-generated method stub
}
}
@@ -17,7 +17,6 @@ import java.util.Calendar;
import oracle.jdbc.OracleParameterMetaData;
import oracle.jdbc.OracleResultSetCache;
import oracle.jdbc.dcn.DatabaseChangeRegistration;
import oracle.sql.ARRAY;
import oracle.sql.BFILE;
import oracle.sql.BINARY_DOUBLE;
@@ -83,25 +82,21 @@ public class OracleMockPreparedStatement extends MockPreparedStatement implement
return executeBatch;
}
@Override
public ResultSet getReturnResultSet() throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public void registerReturnParameter(int arg0, int arg1) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void registerReturnParameter(int arg0, int arg1, int arg2) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void registerReturnParameter(int arg0, int arg1, String arg2) throws SQLException {
// TODO Auto-generated method stub
@@ -257,13 +252,11 @@ public class OracleMockPreparedStatement extends MockPreparedStatement implement
}
@Override
public void setBytesForBlob(int arg0, byte[] arg1) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setBytesForBlobAtName(String arg0, byte[] arg1) throws SQLException {
// TODO Auto-generated method stub
@@ -341,12 +334,6 @@ public class OracleMockPreparedStatement extends MockPreparedStatement implement
}
@Override
public void setDateAtName(String arg0, Date arg1, Calendar arg2) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setDisableStmtCaching(boolean arg0) {
// TODO Auto-generated method stub
@@ -652,19 +639,12 @@ public class OracleMockPreparedStatement extends MockPreparedStatement implement
}
@Override
public void setTimeAtName(String arg0, Time arg1, Calendar arg2) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setTimestampAtName(String arg0, Timestamp arg1) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setTimestampAtName(String arg0, Timestamp arg1, Calendar arg2) throws SQLException {
// TODO Auto-generated method stub
@@ -736,19 +716,16 @@ public class OracleMockPreparedStatement extends MockPreparedStatement implement
}
@Override
public int getLobPrefetchSize() {
// TODO Auto-generated method stub
return 0;
}
@Override
public long getRegisteredQueryId() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public String[] getRegisteredTableNames() throws SQLException {
// TODO Auto-generated method stub
return null;
@@ -765,13 +742,6 @@ public class OracleMockPreparedStatement extends MockPreparedStatement implement
return false;
}
@Override
public void setDatabaseChangeRegistration(DatabaseChangeRegistration arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setLobPrefetchSize(int arg0) throws SQLException {
// TODO Auto-generated method stub
@@ -788,7 +758,6 @@ public class OracleMockPreparedStatement extends MockPreparedStatement implement
this.rowPrefetch = rowPrefetch;
}
@Override
public long getChecksum() throws SQLException {
// TODO Auto-generated method stub
return 0;
@@ -800,12 +769,6 @@ public class OracleMockPreparedStatement extends MockPreparedStatement implement
return false;
}
@Override
public SqlKind getSqlKind() throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public int getcacheState() {
// TODO Auto-generated method stub
@@ -830,12 +793,6 @@ public class OracleMockPreparedStatement extends MockPreparedStatement implement
}
@Override
public void setSnapshotSCN(long arg0) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void enterExplicitCache() throws SQLException {
// TODO Auto-generated method stub
@@ -872,13 +829,11 @@ public class OracleMockPreparedStatement extends MockPreparedStatement implement
}
@Override
public String getOriginalSql() throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public void setCharacterStreamAtName(String arg0, Reader arg1, int arg2) throws SQLException {
// TODO Auto-generated method stub
@@ -31,7 +31,7 @@ public class Oracle_Case4 extends TestCase {
private String validationQuery = "SELECT 1 FROM DUAL";
private int threadCount = 1;
private int loopCount = 3;
final int LOOP_COUNT = 1000 * 1000;
final int LOOP_COUNT = 1000 * 1;
private boolean testOnBorrow = false;
private boolean preparedStatementCache = true;
private int preparedStatementCacheSize = 50;
@@ -40,10 +40,10 @@ public class Oracle_Case4 extends TestCase {
private String SQL;
protected void setUp() throws Exception {
// jdbcUrl = "jdbc:oracle:thin:@10.20.149.85:1521:ocnauto";
// user = "alibaba";
// password = "ccbuauto";
// SQL = "SELECT * FROM WP_ORDERS WHERE ID = ?";
// jdbcUrl = "jdbc:oracle:thin:@10.20.149.85:1521:ocnauto";
// user = "alibaba";
// password = "ccbuauto";
// SQL = "SELECT * FROM WP_ORDERS WHERE ID = ?";
jdbcUrl = "jdbc:oracle:thin:@10.20.149.81:1521:ointest3";
user = "alibaba";
@@ -68,7 +68,7 @@ public class Oracle_Case4 extends TestCase {
dataSource.setValidationQuery(validationQuery);
dataSource.setTestOnBorrow(testOnBorrow);
dataSource.setConnectionProperties(properties);
dataSource.setUseOracleImplicitCache(false);
dataSource.setUseOracleImplicitCache(true);
// printAV_INFO(dataSource);
// printTables(dataSource);
@@ -155,7 +155,7 @@ public class Oracle_Case4 extends TestCase {
int mod = i % 500;
String sql = SQL; // + " AND ROWNUM <= " + (mod + 1);
String sql = SQL + " AND ROWNUM <= " + (mod + 1);
PreparedStatement stmt = conn.prepareStatement(sql);
stmt.setInt(1, 61);
ResultSet rs = stmt.executeQuery();