use of com.alibaba.druid.proxy.jdbc.ClobProxy in project druid by alibaba.
the class FilterChainTest_Clob_2 method test_getObject.
public void test_getObject() throws Exception {
FilterChainImpl chain = new FilterChainImpl(dataSource);
Clob clob = (Clob) chain.callableStatement_getObject(statement, 1);
Assert.assertTrue(clob instanceof ClobProxy);
Assert.assertEquals(1, invokeCount);
}
use of com.alibaba.druid.proxy.jdbc.ClobProxy in project druid by alibaba.
the class FilterChainTest_Clob_2 method test_getObject_1.
public void test_getObject_1() throws Exception {
FilterChainImpl chain = new FilterChainImpl(dataSource);
Clob clob = (Clob) chain.callableStatement_getObject(statement, "1");
Assert.assertTrue(clob instanceof ClobProxy);
Assert.assertEquals(1, invokeCount);
}
use of com.alibaba.druid.proxy.jdbc.ClobProxy in project druid by alibaba.
the class FilterChainTest_Clob_2 method test_getClob_1.
public void test_getClob_1() throws Exception {
FilterChainImpl chain = new FilterChainImpl(dataSource);
Clob clob = chain.callableStatement_getClob(statement, "1");
Assert.assertTrue(clob instanceof ClobProxy);
Assert.assertEquals(1, invokeCount);
}
use of com.alibaba.druid.proxy.jdbc.ClobProxy in project druid by alibaba.
the class FilterChainTest_Clob_2 method test_getObject_3.
public void test_getObject_3() throws Exception {
FilterChainImpl chain = new FilterChainImpl(dataSource);
Clob clob = (Clob) chain.callableStatement_getObject(statement, "1", Collections.<String, Class<?>>emptyMap());
Assert.assertTrue(clob instanceof ClobProxy);
Assert.assertEquals(1, invokeCount);
}
use of com.alibaba.druid.proxy.jdbc.ClobProxy in project druid by alibaba.
the class ClobTest method test_clob.
public void test_clob() throws Exception {
Connection conn = null;
PreparedStatement pstmt = null;
Statement stmt = null;
ResultSet rs = null;
try {
conn = DriverManager.getConnection(create_url);
pstmt = conn.prepareStatement("INSERT INTO T_CLOB (ID, DATA) VALUES (?, ?)");
Clob clob = conn.createClob();
ClobProxy clobWrapper = (ClobProxy) clob;
Assert.assertNotNull(clobWrapper.getConnectionWrapper());
clob.setAsciiStream(1);
clob.setCharacterStream(1);
clob.setString(1, "ABCAAAAAAAAAAA");
clob.setString(1, "ABCAAAAAAAAAAA", 1, 5);
pstmt.setInt(1, 1);
pstmt.setClob(2, clob);
int updateCount = pstmt.executeUpdate();
Assert.assertEquals(1, updateCount);
pstmt.setInt(1, 1);
pstmt.setClob(2, new StringReader("XXXXXXX"));
updateCount = pstmt.executeUpdate();
Assert.assertEquals(1, updateCount);
pstmt.setInt(1, 1);
pstmt.setClob(2, new StringReader("ABCAAAAAAAAAAABCAAAAAAAAAAAAABCAAAAAAAAAAABCAAAAAAAAAAAA"), "ABCAAAAAAAAAAABCAAAAAAAAAAAAABCAAAAAAAAAAABCAAAAAAAAAAAA".length());
updateCount = pstmt.executeUpdate();
Assert.assertEquals(1, updateCount);
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE, ResultSet.CLOSE_CURSORS_AT_COMMIT);
// //////
rs = stmt.executeQuery("SELECT ID, DATA FROM T_CLOB");
// just call
rs.getStatement();
while (rs.next()) {
Clob readClob = rs.getClob(2);
readClob.length();
readClob.position("abc", 1);
readClob.getCharacterStream().close();
readClob.getAsciiStream().close();
readClob.getCharacterStream(1, 1).close();
readClob.getSubString(1, 2);
readClob.truncate(2);
readClob.free();
}
JdbcUtils.close(rs);
rs = stmt.executeQuery("SELECT ID, DATA FROM T_CLOB");
while (rs.next()) {
rs.getCharacterStream(2).close();
}
JdbcUtils.close(rs);
rs = stmt.executeQuery("SELECT ID, DATA FROM T_CLOB");
while (rs.next()) {
rs.getCharacterStream("DATA").close();
}
JdbcUtils.close(rs);
rs = stmt.executeQuery("SELECT ID, DATA FROM T_CLOB");
while (rs.next()) {
Clob searchstr = conn.createClob();
searchstr.setString(1, "AB");
Clob x = rs.getClob("DATA");
x.position(searchstr, 1);
x.free();
}
JdbcUtils.close(rs);
rs = stmt.executeQuery("SELECT ID, DATA FROM T_CLOB");
while (rs.next()) {
rs.getAsciiStream(2).close();
}
JdbcUtils.close(rs);
rs = stmt.executeQuery("SELECT ID, DATA FROM T_CLOB");
while (rs.next()) {
rs.getAsciiStream("DATA").close();
}
JdbcUtils.close(rs);
rs = stmt.executeQuery("SELECT ID, DATA FROM T_CLOB");
while (rs.next()) {
Clob x = conn.createClob();
x.setString(1, "XXSDDSLF");
rs.updateClob(2, x);
}
JdbcUtils.close(rs);
rs = stmt.executeQuery("SELECT ID, DATA FROM T_CLOB");
while (rs.next()) {
Clob x = conn.createClob();
x.setString(1, "XXSDDSLF");
rs.updateClob("DATA", x);
}
JdbcUtils.close(rs);
rs = stmt.executeQuery("SELECT ID, DATA FROM T_CLOB");
while (rs.next()) {
rs.updateClob(2, new StringReader("XDSFLA"));
}
JdbcUtils.close(rs);
rs = stmt.executeQuery("SELECT ID, DATA FROM T_CLOB");
while (rs.next()) {
rs.updateClob("DATA", new StringReader("XDSFLA"));
}
rs = stmt.executeQuery("SELECT ID, DATA FROM T_CLOB");
while (rs.next()) {
rs.updateClob(2, new StringReader("XDSFLA"), "XDSFLA".length());
}
JdbcUtils.close(rs);
rs = stmt.executeQuery("SELECT ID, DATA FROM T_CLOB");
while (rs.next()) {
rs.updateClob("DATA", new StringReader("XDSFLA"), "XDSFLA".length());
}
JdbcUtils.close(rs);
} finally {
JdbcUtils.close(rs);
JdbcUtils.close(stmt);
JdbcUtils.close(pstmt);
JdbcUtils.close(conn);
}
}
Aggregations