修正Clob和NClob的问题

git-svn-id: http://code.alibabatech.com/svn/druid/trunk@60 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
wenshao
2011-05-13 14:42:52 +00:00
parent 0736e6c71c
commit 978519c054
4 changed files with 89 additions and 17 deletions
@@ -52,6 +52,8 @@ import com.alibaba.druid.proxy.jdbc.ClobProxyImpl;
import com.alibaba.druid.proxy.jdbc.ConnectionProxy;
import com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl;
import com.alibaba.druid.proxy.jdbc.DataSourceProxy;
import com.alibaba.druid.proxy.jdbc.NClobProxy;
import com.alibaba.druid.proxy.jdbc.NClobProxyImpl;
import com.alibaba.druid.proxy.jdbc.PreparedStatementProxy;
import com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl;
import com.alibaba.druid.proxy.jdbc.ResultSetProxy;
@@ -171,11 +173,11 @@ public class FilterChainImpl implements FilterChain {
}
Clob clob = connection.getConnectionRaw().createClob();
if (clob == null) {
return null;
}
return wrap(connection, clob);
}
@@ -185,7 +187,13 @@ public class FilterChainImpl implements FilterChain {
return nextFilter().connection_createNClob(this, connection);
}
return connection.getConnectionRaw().createNClob();
NClob nclob = connection.getConnectionRaw().createNClob();
if (nclob == null) {
return null;
}
return wrap(connection, nclob);
}
@Override
@@ -1623,7 +1631,7 @@ public class FilterChainImpl implements FilterChain {
}
Clob clob = resultSet.getResultSetRaw().getClob(columnIndex);
if (clob == null) {
return null;
}
@@ -1674,11 +1682,11 @@ public class FilterChainImpl implements FilterChain {
}
Clob clob = resultSet.getResultSetRaw().getClob(columnLabel);
if (clob == null) {
return null;
}
return wrap(resultSet.getStatementProxy().getConnectionProxy(), clob);
}
@@ -1923,7 +1931,14 @@ public class FilterChainImpl implements FilterChain {
if (this.pos < filterSize) {
return nextFilter().resultSet_getNClob(this, resultSet, columnIndex);
}
return resultSet.getResultSetRaw().getNClob(columnIndex);
NClob nclob = resultSet.getResultSetRaw().getNClob(columnIndex);
if (nclob == null) {
return null;
}
return wrap(resultSet.getStatementProxy().getConnectionProxy(), nclob);
}
@Override
@@ -1931,7 +1946,14 @@ public class FilterChainImpl implements FilterChain {
if (this.pos < filterSize) {
return nextFilter().resultSet_getNClob(this, resultSet, columnLabel);
}
return resultSet.getResultSetRaw().getNClob(columnLabel);
NClob nclob = resultSet.getResultSetRaw().getNClob(columnLabel);
if (nclob == null) {
return null;
}
return wrap(resultSet.getStatementProxy().getConnectionProxy(), nclob);
}
@Override
@@ -1939,6 +1961,7 @@ public class FilterChainImpl implements FilterChain {
if (this.pos < filterSize) {
return nextFilter().resultSet_getSQLXML(this, resultSet, columnIndex);
}
return resultSet.getResultSetRaw().getSQLXML(columnIndex);
}
@@ -3352,11 +3375,11 @@ public class FilterChainImpl implements FilterChain {
}
Clob clob = statement.getRawCallableStatement().getClob(parameterIndex);
if (clob == null) {
return null;
}
return wrap(statement.getConnectionProxy(), clob);
}
@@ -3846,11 +3869,11 @@ public class FilterChainImpl implements FilterChain {
}
Clob clob = statement.getRawCallableStatement().getClob(parameterName);
if (clob == null) {
return null;
}
return wrap(statement.getConnectionProxy(), clob);
}
@@ -3989,7 +4012,14 @@ public class FilterChainImpl implements FilterChain {
if (this.pos < filterSize) {
return nextFilter().callableStatement_getNClob(this, statement, parameterIndex);
}
return statement.getRawCallableStatement().getNClob(parameterIndex);
NClob nclob = statement.getRawCallableStatement().getNClob(parameterIndex);
if (nclob == null) {
return null;
}
return wrap(statement.getConnectionProxy(), nclob);
}
@Override
@@ -3997,7 +4027,14 @@ public class FilterChainImpl implements FilterChain {
if (this.pos < filterSize) {
return nextFilter().callableStatement_getNClob(this, statement, parameterName);
}
return statement.getRawCallableStatement().getNClob(parameterName);
NClob nclob = statement.getRawCallableStatement().getNClob(parameterName);
if (nclob == null) {
return null;
}
return wrap(statement.getConnectionProxy(), nclob);
}
@Override
@@ -4335,7 +4372,10 @@ public class FilterChainImpl implements FilterChain {
public ClobProxy wrap(ConnectionProxy connection, Clob clob) {
return new ClobProxyImpl(dataSource, connection, clob);
}
public NClobProxy wrap(ConnectionProxy connection, NClob clob) {
return new NClobProxyImpl(dataSource, connection, clob);
}
private final AtomicLong connectionIdSeed = new AtomicLong(10000);
@@ -30,10 +30,10 @@ import com.alibaba.druid.filter.FilterChainImpl;
*/
public class ClobProxyImpl implements ClobProxy {
private final Clob clob;
private final ConnectionProxy connection;
protected final Clob clob;
protected final ConnectionProxy connection;
private final DataSourceProxy dataSource;
protected final DataSourceProxy dataSource;
public ClobProxyImpl(DataSourceProxy dataSource, ConnectionProxy connection, Clob clob){
this.dataSource = dataSource;
@@ -0,0 +1,7 @@
package com.alibaba.druid.proxy.jdbc;
import java.sql.NClob;
public interface NClobProxy extends ClobProxy, NClob {
NClob getRawNClob();
}
@@ -0,0 +1,25 @@
package com.alibaba.druid.proxy.jdbc;
import java.sql.NClob;
import com.alibaba.druid.filter.FilterChain;
import com.alibaba.druid.filter.FilterChainImpl;
public class NClobProxyImpl extends ClobProxyImpl implements NClobProxy {
private final NClob nclob;
public NClobProxyImpl(DataSourceProxy dataSource, ConnectionProxy connection, NClob clob){
super(dataSource, connection, clob);
this.nclob = clob;
}
public FilterChain createChain() {
return new FilterChainImpl(dataSource);
}
@Override
public NClob getRawNClob() {
return nclob;
}
}