optimized for oracle

This commit is contained in:
wenshao
2011-12-30 13:52:50 +08:00
parent 8c4471c4c9
commit 3948a5ede6
10 changed files with 214 additions and 22 deletions
@@ -290,6 +290,10 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
if ("oracle".equals(this.dbType)) {
isOracle = true;
if (driver.getMajorVersion() < 10) {
throw new SQLException("not support oracle driver " + driver.getMajorVersion() + "." + driver.getMinorVersion());
}
}
String realDriverClassName = driver.getClass().getName();
@@ -5,7 +5,7 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
import oracle.jdbc.OracleConnection;
import oracle.jdbc.driver.OracleStatement;
import oracle.jdbc.OracleStatement;
public class OracleUtils {
@@ -30,11 +30,17 @@ public class OracleUtils {
}
public static int getDefaultRowPrefetch(Connection conn, int value) throws SQLException {
if (conn instanceof OracleConnection) {
OracleConnection oracleConn = (OracleConnection) conn;
return oracleConn.getDefaultRowPrefetch();
}
OracleConnection oracleConn = conn.unwrap(OracleConnection.class);
return oracleConn.getDefaultRowPrefetch();
}
return -1;
public static void cancel(Connection conn) throws SQLException {
OracleConnection oracleConn = conn.unwrap(OracleConnection.class);
oracleConn.cancel();
}
public static void pingDatabase(Connection conn) throws SQLException {
OracleConnection oracleConn = conn.unwrap(OracleConnection.class);
oracleConn.pingDatabase();
}
}
@@ -173,7 +173,7 @@ public class PoolablePreparedStatement extends PoolableStatement implements Prep
incrementExecuteCount();
transactionRecord(sql);
oracleSetRowPrefetch();
// oracleSetRowPrefetch();
try {
ResultSet rs = stmt.executeQuery();
@@ -429,7 +429,7 @@ public class PoolablePreparedStatement extends PoolableStatement implements Prep
incrementExecuteCount();
transactionRecord(sql);
oracleSetRowPrefetch();
// oracleSetRowPrefetch();
try {
return stmt.execute();
@@ -438,7 +438,7 @@ public class PoolablePreparedStatement extends PoolableStatement implements Prep
}
}
private void oracleSetRowPrefetch() throws SQLException {
protected void oracleSetRowPrefetch() throws SQLException {
if (!conn.isOracle()) {
return;
}
@@ -446,7 +446,7 @@ public class PoolablePreparedStatement extends PoolableStatement implements Prep
if (holder.getHitCount() == 0) {
return;
}
int fetchRowPeak = holder.getFetchRowPeak();
if (fetchRowPeak < 0) {