mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
optimized for oracle
This commit is contained in:
@@ -4,28 +4,50 @@ import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import oracle.jdbc.OracleConnection;
|
||||
import oracle.jdbc.OraclePreparedStatement;
|
||||
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
import com.alibaba.druid.util.OracleUtils;
|
||||
|
||||
public class TestOraclePreparedStatement extends TestCase {
|
||||
|
||||
private String jdbcUrl;
|
||||
private String user;
|
||||
private String password;
|
||||
private String SQL;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
jdbcUrl = "jdbc:oracle:thin:@10.20.149.85:1521:ocnauto";
|
||||
// jdbcUrl = "jdbc:oracle:thin:@20.20.149.85:1521:ocnauto"; // error url
|
||||
user = "alibaba";
|
||||
password = "ccbuauto";
|
||||
|
||||
jdbcUrl = "jdbc:oracle:thin:@10.20.149.81:1521:ointest3";
|
||||
user = "alibaba";
|
||||
password = "deYcR7facWSJtCuDpm2r";
|
||||
SQL = "SELECT * FROM AV_INFO WHERE ID = ?";
|
||||
|
||||
Class.forName(JdbcUtils.getDriverClassName(jdbcUrl));
|
||||
}
|
||||
|
||||
public void createTable() throws Exception {
|
||||
Connection conn = DriverManager.getConnection(jdbcUrl, user, password);
|
||||
|
||||
Statement stmt = conn.createStatement();
|
||||
stmt.execute("DROP TABLE T");
|
||||
;
|
||||
stmt.execute("CREATE TABLE T (FID INT, FNAME VARCHAR2(4000), FDESC CLOB)");
|
||||
;
|
||||
stmt.close();
|
||||
|
||||
conn.close();
|
||||
}
|
||||
|
||||
public void test_0() throws Exception {
|
||||
Class.forName(JdbcUtils.getDriverClassName(jdbcUrl));
|
||||
|
||||
Connection conn = DriverManager.getConnection(jdbcUrl, user, password);
|
||||
|
||||
@@ -37,12 +59,22 @@ public class TestOraclePreparedStatement extends TestCase {
|
||||
|
||||
int fetchRowSize = oracleConn.getDefaultRowPrefetch();
|
||||
|
||||
String sql = "SELECT * FROM WP_ORDERS WHERE ID <= ?";
|
||||
// {
|
||||
// oracleConn.setStatementCacheSize(10);
|
||||
// oracleConn.setImplicitCachingEnabled(true);
|
||||
//
|
||||
// PreparedStatement stmt = conn.prepareStatement(SQL);
|
||||
// stmt.close();
|
||||
//
|
||||
// PreparedStatement stmt2 = conn.prepareStatement(SQL);
|
||||
// stmt2.close();
|
||||
// }
|
||||
|
||||
OraclePreparedStatement oracleStmt = null;
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
PreparedStatement stmt = conn.prepareStatement(SQL);
|
||||
oracleStmt = (OraclePreparedStatement) stmt;
|
||||
oracleStmt.setRowPrefetch(10);
|
||||
|
||||
{
|
||||
|
||||
stmt.setInt(1, 327);
|
||||
@@ -53,8 +85,21 @@ public class TestOraclePreparedStatement extends TestCase {
|
||||
|
||||
rs.close();
|
||||
|
||||
oracleStmt.clearDefines();
|
||||
//oracleStmt.clearDefines();
|
||||
}
|
||||
for (int i = 0; i < 10; ++i){
|
||||
OracleUtils.enterImplicitCache(oracleStmt);
|
||||
OracleUtils.exitImplicitCacheToActive(oracleStmt);
|
||||
stmt.setInt(1, 327);
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
|
||||
}
|
||||
|
||||
rs.close();
|
||||
|
||||
}
|
||||
|
||||
oracleStmt.setRowPrefetch(1000);
|
||||
{
|
||||
stmt.setInt(1, 11);
|
||||
|
||||
Reference in New Issue
Block a user