mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
support dynamic preparedstatement.
This commit is contained in:
@@ -288,7 +288,9 @@ public class DruidPooledStatement extends PoolableWrapper implements Statement {
|
||||
public void close() throws SQLException {
|
||||
if (!this.closed) {
|
||||
clearResultSet();
|
||||
stmt.close();
|
||||
if (stmt != null) {
|
||||
stmt.close();
|
||||
}
|
||||
this.closed = true;
|
||||
|
||||
if (conn.getConnectionHolder() != null) {
|
||||
|
||||
@@ -47,7 +47,7 @@ import com.alibaba.druid.proxy.jdbc.JdbcParameter.TYPE;
|
||||
*/
|
||||
public class PreparedStatementProxyImpl extends StatementProxyImpl implements PreparedStatementProxy {
|
||||
|
||||
protected final PreparedStatement statement;
|
||||
private PreparedStatement statement;
|
||||
protected final String sql;
|
||||
private JdbcParameter[] parameters = new JdbcParameter[16];
|
||||
private int parametersSize = 0;
|
||||
@@ -70,6 +70,11 @@ public class PreparedStatementProxyImpl extends StatementProxyImpl implements Pr
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
protected void setStatement(PreparedStatement statement) {
|
||||
super.statement = statement;
|
||||
this.statement = statement;
|
||||
}
|
||||
|
||||
void setParameter(int jdbcIndex, JdbcParameter parameter) {
|
||||
int index = jdbcIndex - 1;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ import com.alibaba.druid.stat.JdbcSqlStat;
|
||||
public class StatementProxyImpl extends WrapperProxyImpl implements StatementProxy {
|
||||
|
||||
private final ConnectionProxy connection;
|
||||
private final Statement statement;
|
||||
protected Statement statement;
|
||||
|
||||
protected String lastExecuteSql;
|
||||
protected long lastExecuteStartNano;
|
||||
@@ -94,6 +94,10 @@ public class StatementProxyImpl extends WrapperProxyImpl implements StatementPro
|
||||
|
||||
@Override
|
||||
public void cancel() throws SQLException {
|
||||
if (this.statement == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
FilterChainImpl chain = createChain();
|
||||
chain.statement_cancel(this);
|
||||
recycleFilterChain(chain);
|
||||
@@ -101,6 +105,10 @@ public class StatementProxyImpl extends WrapperProxyImpl implements StatementPro
|
||||
|
||||
@Override
|
||||
public void clearBatch() throws SQLException {
|
||||
if (this.statement == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (batchSqlList == null) {
|
||||
batchSqlList = new ArrayList<String>();
|
||||
}
|
||||
@@ -113,6 +121,10 @@ public class StatementProxyImpl extends WrapperProxyImpl implements StatementPro
|
||||
|
||||
@Override
|
||||
public void clearWarnings() throws SQLException {
|
||||
if (this.statement == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
FilterChainImpl chain = createChain();
|
||||
chain.statement_clearWarnings(this);
|
||||
recycleFilterChain(chain);
|
||||
@@ -120,6 +132,10 @@ public class StatementProxyImpl extends WrapperProxyImpl implements StatementPro
|
||||
|
||||
@Override
|
||||
public void close() throws SQLException {
|
||||
if (this.statement == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
FilterChainImpl chain = createChain();
|
||||
chain.statement_close(this);
|
||||
recycleFilterChain(chain);
|
||||
|
||||
Reference in New Issue
Block a user