mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor
This commit is contained in:
@@ -18,8 +18,6 @@ package com.alibaba.druid.filter.logging;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.druid.filter.FilterChain;
|
||||
import com.alibaba.druid.filter.FilterEventAdapter;
|
||||
@@ -68,9 +66,6 @@ public abstract class LogFilter extends FilterEventAdapter implements LogFilterM
|
||||
private boolean resultSetLogEnabled = true;
|
||||
private boolean resultSetLogErrorEnabled = true;
|
||||
|
||||
protected final String attributeNameParameter = "log.parameter";
|
||||
protected final String attributeNameLastSql = "log.lastSql";
|
||||
|
||||
protected DataSourceProxy dataSource;
|
||||
|
||||
public LogFilter(){
|
||||
@@ -327,16 +322,12 @@ public abstract class LogFilter extends FilterEventAdapter implements LogFilterM
|
||||
|
||||
@Override
|
||||
protected void statementExecuteBefore(StatementProxy statement, String sql) {
|
||||
setLastSql(statement, sql);
|
||||
|
||||
if (statement instanceof PreparedStatementProxy) {
|
||||
logParameter((PreparedStatementProxy) statement);
|
||||
}
|
||||
}
|
||||
|
||||
private void setLastSql(StatementProxy statement, String sql) {
|
||||
statement.getAttributes().put(attributeNameLastSql, sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statementExecuteAfter(StatementProxy statement, String sql, boolean firstResult) {
|
||||
@@ -363,7 +354,6 @@ public abstract class LogFilter extends FilterEventAdapter implements LogFilterM
|
||||
|
||||
@Override
|
||||
protected void statementExecuteQueryBefore(StatementProxy statement, String sql) {
|
||||
setLastSql(statement, sql);
|
||||
|
||||
if (statement instanceof PreparedStatementProxy) {
|
||||
logParameter((PreparedStatementProxy) statement);
|
||||
@@ -380,7 +370,6 @@ public abstract class LogFilter extends FilterEventAdapter implements LogFilterM
|
||||
|
||||
@Override
|
||||
protected void statementExecuteUpdateBefore(StatementProxy statement, String sql) {
|
||||
setLastSql(statement, sql);
|
||||
|
||||
if (statement instanceof PreparedStatementProxy) {
|
||||
logParameter((PreparedStatementProxy) statement);
|
||||
@@ -532,21 +521,7 @@ public abstract class LogFilter extends FilterEventAdapter implements LogFilterM
|
||||
|
||||
protected void preparedStatement_setParameterBefore(PreparedStatementProxy statement, int parameterIndex,
|
||||
int sqlType, Object... values) {
|
||||
JdbcParameter parameter = new JdbcParameter(sqlType, values);
|
||||
|
||||
getParameters(statement).put(parameterIndex, parameter);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<Integer, JdbcParameter> getParameters(PreparedStatementProxy statement) {
|
||||
Map<Integer, JdbcParameter> parameters = (Map<Integer, JdbcParameter>) statement.getAttributes().get(attributeNameParameter);
|
||||
|
||||
if (parameters == null) {
|
||||
statement.getAttributes().put(attributeNameParameter, new HashMap<Integer, JdbcParameter>());
|
||||
parameters = (Map<Integer, JdbcParameter>) statement.getAttributes().get(attributeNameParameter);
|
||||
}
|
||||
|
||||
return parameters;
|
||||
}
|
||||
|
||||
protected void logParameter(PreparedStatementProxy statement) {
|
||||
@@ -560,18 +535,18 @@ public abstract class LogFilter extends FilterEventAdapter implements LogFilterM
|
||||
buf.append("}");
|
||||
buf.append(" Parameters : [");
|
||||
int parameterIndex = 0;
|
||||
for (JdbcParameter parameter : getParameters(statement).values()) {
|
||||
for (JdbcParameter parameter : statement.getParameters().values()) {
|
||||
if (parameterIndex != 0) {
|
||||
buf.append(", ");
|
||||
}
|
||||
int sqlType = parameter.getSqlType();
|
||||
Object[] values = parameter.getValues();
|
||||
Object value = parameter.getValue();
|
||||
switch (sqlType) {
|
||||
case Types.NULL:
|
||||
buf.append("NULL");
|
||||
break;
|
||||
default:
|
||||
buf.append(String.valueOf(values[0]));
|
||||
buf.append(String.valueOf(value));
|
||||
break;
|
||||
}
|
||||
parameterIndex++;
|
||||
@@ -588,7 +563,7 @@ public abstract class LogFilter extends FilterEventAdapter implements LogFilterM
|
||||
buf.append("}");
|
||||
buf.append(" Types : [");
|
||||
int parameterIndex = 0;
|
||||
for (JdbcParameter parameter : getParameters(statement).values()) {
|
||||
for (JdbcParameter parameter : statement.getParameters().values()) {
|
||||
if (parameterIndex != 0) {
|
||||
buf.append(", ");
|
||||
}
|
||||
|
||||
@@ -15,27 +15,59 @@
|
||||
*/
|
||||
package com.alibaba.druid.proxy.jdbc;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* @author wenshao<szujobs@hotmail.com>
|
||||
*/
|
||||
public class JdbcParameter {
|
||||
|
||||
private final int sqlType;
|
||||
private final Object[] values;
|
||||
public static final int BinaryInputStream = 10001;
|
||||
public static final int AsciiInputStream = 10002;
|
||||
public static final int CharacterInputStream = 10003;
|
||||
public static final int NCharacterInputStream = 10004;
|
||||
public static final int URL = 10005;
|
||||
|
||||
public JdbcParameter(int sqlType, Object[] values){
|
||||
private final int sqlType;
|
||||
private final Object value;
|
||||
private final long length;
|
||||
private final Calendar calendar;
|
||||
|
||||
public JdbcParameter(int sqlType, Object value, long length, Calendar calendar){
|
||||
this.sqlType = sqlType;
|
||||
this.values = values;
|
||||
this.value = value;
|
||||
this.length = length;
|
||||
this.calendar = calendar;
|
||||
}
|
||||
|
||||
public JdbcParameter(int sqlType, Object value){
|
||||
this(sqlType, value, -1, null);
|
||||
}
|
||||
|
||||
public JdbcParameter(int sqlType, Object value, long length){
|
||||
this(sqlType, value, length, null);
|
||||
}
|
||||
|
||||
public JdbcParameter(int sqlType, Object value, Calendar calendar){
|
||||
this(sqlType, value, -1, calendar);
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public long getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public Calendar getCalendar() {
|
||||
return calendar;
|
||||
}
|
||||
|
||||
public int getSqlType() {
|
||||
return sqlType;
|
||||
}
|
||||
|
||||
public Object[] getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public static interface TYPE {
|
||||
|
||||
public static final int BinaryInputStream = 10001;
|
||||
@@ -43,6 +75,8 @@ public class JdbcParameter {
|
||||
public static final int CharacterInputStream = 10003;
|
||||
public static final int NCharacterInputStream = 10004;
|
||||
public static final int URL = 10005;
|
||||
public static final int UnicodeStream = 10006;
|
||||
public static final int BYTES = 10007;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.alibaba.druid.proxy.jdbc;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author wenshao<szujobs@hotmail.com>
|
||||
@@ -25,4 +26,6 @@ public interface PreparedStatementProxy extends PreparedStatement, StatementProx
|
||||
String getSql();
|
||||
|
||||
PreparedStatement getRawObject();
|
||||
|
||||
Map<Integer, JdbcParameter> getParameters();
|
||||
}
|
||||
|
||||
@@ -34,15 +34,21 @@ import java.sql.SQLException;
|
||||
import java.sql.SQLXML;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
import java.sql.Types;
|
||||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.alibaba.druid.proxy.jdbc.JdbcParameter.TYPE;
|
||||
|
||||
/**
|
||||
* @author wenshao<szujobs@hotmail.com>
|
||||
*/
|
||||
public class PreparedStatementProxyImpl extends StatementProxyImpl implements PreparedStatementProxy {
|
||||
|
||||
protected final PreparedStatement statement;
|
||||
protected final String sql;
|
||||
protected final PreparedStatement statement;
|
||||
protected final String sql;
|
||||
protected final Map<Integer, JdbcParameter> parameters = new TreeMap<Integer, JdbcParameter>();
|
||||
|
||||
public PreparedStatementProxyImpl(ConnectionProxy connection, PreparedStatement statement, String sql, long id){
|
||||
super(connection, statement, id);
|
||||
@@ -50,6 +56,10 @@ public class PreparedStatementProxyImpl extends StatementProxyImpl implements Pr
|
||||
this.sql = sql;
|
||||
}
|
||||
|
||||
public Map<Integer, JdbcParameter> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public String getSql() {
|
||||
return this.sql;
|
||||
}
|
||||
@@ -100,255 +110,352 @@ public class PreparedStatementProxyImpl extends StatementProxyImpl implements Pr
|
||||
|
||||
@Override
|
||||
public void setArray(int parameterIndex, Array x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.ARRAY, x));
|
||||
|
||||
createChain().preparedStatement_setArray(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(JdbcParameter.TYPE.AsciiInputStream, x));
|
||||
|
||||
createChain().preparedStatement_setAsciiStream(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(JdbcParameter.TYPE.AsciiInputStream, x, length));
|
||||
|
||||
createChain().preparedStatement_setAsciiStream(this, parameterIndex, x, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(JdbcParameter.TYPE.AsciiInputStream, x, length));
|
||||
|
||||
createChain().preparedStatement_setAsciiStream(this, parameterIndex, x, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.DECIMAL, x));
|
||||
createChain().preparedStatement_setBigDecimal(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(JdbcParameter.TYPE.BinaryInputStream, x));
|
||||
|
||||
createChain().preparedStatement_setBinaryStream(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(JdbcParameter.TYPE.BinaryInputStream, x, length));
|
||||
|
||||
createChain().preparedStatement_setBinaryStream(this, parameterIndex, x, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(JdbcParameter.TYPE.BinaryInputStream, x, length));
|
||||
|
||||
createChain().preparedStatement_setBinaryStream(this, parameterIndex, x, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlob(int parameterIndex, Blob x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.BLOB, x));
|
||||
|
||||
createChain().preparedStatement_setBlob(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlob(int parameterIndex, InputStream x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.BLOB, x));
|
||||
|
||||
createChain().preparedStatement_setBlob(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlob(int parameterIndex, InputStream x, long length) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.BLOB, x, length));
|
||||
createChain().preparedStatement_setBlob(this, parameterIndex, x, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoolean(int parameterIndex, boolean x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.BOOLEAN, x));
|
||||
createChain().preparedStatement_setBoolean(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setByte(int parameterIndex, byte x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.TINYINT, x));
|
||||
|
||||
createChain().preparedStatement_setByte(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int parameterIndex, byte[] x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(TYPE.BYTES, x));
|
||||
|
||||
createChain().preparedStatement_setBytes(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCharacterStream(int parameterIndex, Reader x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(TYPE.CharacterInputStream, x));
|
||||
|
||||
createChain().preparedStatement_setCharacterStream(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCharacterStream(int parameterIndex, Reader x, int length) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(TYPE.CharacterInputStream, x, length));
|
||||
|
||||
createChain().preparedStatement_setCharacterStream(this, parameterIndex, x, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCharacterStream(int parameterIndex, Reader x, long length) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(TYPE.CharacterInputStream, x, length));
|
||||
|
||||
createChain().preparedStatement_setCharacterStream(this, parameterIndex, x, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClob(int parameterIndex, Clob x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.CLOB, x));
|
||||
|
||||
createChain().preparedStatement_setClob(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClob(int parameterIndex, Reader x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.CLOB, x));
|
||||
|
||||
createChain().preparedStatement_setClob(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClob(int parameterIndex, Reader x, long length) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.CLOB, x, length));
|
||||
|
||||
createChain().preparedStatement_setClob(this, parameterIndex, x, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDate(int parameterIndex, Date x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.DATE, x));
|
||||
|
||||
createChain().preparedStatement_setDate(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.DATE, x, cal));
|
||||
|
||||
createChain().preparedStatement_setDate(this, parameterIndex, x, cal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDouble(int parameterIndex, double x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.DOUBLE, x));
|
||||
|
||||
createChain().preparedStatement_setDouble(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFloat(int parameterIndex, float x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.FLOAT, x));
|
||||
|
||||
createChain().preparedStatement_setFloat(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInt(int parameterIndex, int x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.INTEGER, x));
|
||||
|
||||
createChain().preparedStatement_setInt(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLong(int parameterIndex, long x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.BIGINT, x));
|
||||
|
||||
createChain().preparedStatement_setLong(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNCharacterStream(int parameterIndex, Reader x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(TYPE.NCharacterInputStream, x));
|
||||
|
||||
createChain().preparedStatement_setNCharacterStream(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNCharacterStream(int parameterIndex, Reader x, long length) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(TYPE.NCharacterInputStream, x,length));
|
||||
|
||||
createChain().preparedStatement_setNCharacterStream(this, parameterIndex, x, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNClob(int parameterIndex, NClob x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.NCLOB, x));
|
||||
|
||||
createChain().preparedStatement_setNClob(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNClob(int parameterIndex, Reader x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.NCLOB, x));
|
||||
|
||||
createChain().preparedStatement_setNClob(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNClob(int parameterIndex, Reader x, long length) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.NCLOB, x, length));
|
||||
|
||||
createChain().preparedStatement_setNClob(this, parameterIndex, x, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNString(int parameterIndex, String x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.NVARCHAR, x));
|
||||
|
||||
createChain().preparedStatement_setNString(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNull(int parameterIndex, int sqlType) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(sqlType, null));
|
||||
|
||||
createChain().preparedStatement_setNull(this, parameterIndex, sqlType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(sqlType, null));
|
||||
|
||||
createChain().preparedStatement_setNull(this, parameterIndex, sqlType, typeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setObject(int parameterIndex, Object x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.OTHER, null));
|
||||
|
||||
createChain().preparedStatement_setObject(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(targetSqlType, x));
|
||||
|
||||
createChain().preparedStatement_setObject(this, parameterIndex, x, targetSqlType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(targetSqlType, x));
|
||||
|
||||
createChain().preparedStatement_setObject(this, parameterIndex, x, targetSqlType, scaleOrLength);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRef(int parameterIndex, Ref x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.REF, x));
|
||||
|
||||
createChain().preparedStatement_setRef(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRowId(int parameterIndex, RowId x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.ROWID, x));
|
||||
|
||||
createChain().preparedStatement_setRowId(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSQLXML(int parameterIndex, SQLXML x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.SQLXML, x));
|
||||
|
||||
createChain().preparedStatement_setSQLXML(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShort(int parameterIndex, short x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.SMALLINT, x));
|
||||
|
||||
createChain().preparedStatement_setShort(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setString(int parameterIndex, String x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.VARCHAR, x));
|
||||
|
||||
createChain().preparedStatement_setString(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTime(int parameterIndex, Time x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.TIME, x));
|
||||
|
||||
createChain().preparedStatement_setTime(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.TIME, x, cal));
|
||||
|
||||
createChain().preparedStatement_setTime(this, parameterIndex, x, cal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.TIMESTAMP, x));
|
||||
|
||||
createChain().preparedStatement_setTimestamp(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(Types.TIMESTAMP, x));
|
||||
|
||||
createChain().preparedStatement_setTimestamp(this, parameterIndex, x, cal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setURL(int parameterIndex, URL x) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(TYPE.URL, x));
|
||||
|
||||
createChain().preparedStatement_setURL(this, parameterIndex, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException {
|
||||
setParameter(parameterIndex, new JdbcParameter(TYPE.UnicodeStream, x, length));
|
||||
|
||||
createChain().preparedStatement_setUnicodeStream(this, parameterIndex, x, length);
|
||||
}
|
||||
|
||||
public void setParameter(int parameterIndex, JdbcParameter parameter) {
|
||||
this.getParameters().put(parameterIndex, parameter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLastExecuteSql() {
|
||||
return this.sql;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||
if (iface == PreparedStatement.class) {
|
||||
return (T) statement;
|
||||
}
|
||||
|
||||
|
||||
return super.unwrap(iface);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user