mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@71 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -0,0 +1,151 @@
|
||||
package com.alibaba.druid.mock;
|
||||
|
||||
import java.sql.ParameterMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MockParameterMetaData implements ParameterMetaData {
|
||||
|
||||
public MockParameterMetaData(){
|
||||
|
||||
}
|
||||
|
||||
private final List<Parameter> parameters = new ArrayList<Parameter>();
|
||||
|
||||
public List<Parameter> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWrapperFor(Class<?> iface) throws SQLException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getParameterCount() throws SQLException {
|
||||
return parameters.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isNullable(int param) throws SQLException {
|
||||
return parameters.get(param - 1).getNullable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSigned(int param) throws SQLException {
|
||||
return parameters.get(param - 1).isSigned();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrecision(int param) throws SQLException {
|
||||
return parameters.get(param - 1).getPrecision();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScale(int param) throws SQLException {
|
||||
return parameters.get(param - 1).getScale();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getParameterType(int param) throws SQLException {
|
||||
return parameters.get(param - 1).getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameterTypeName(int param) throws SQLException {
|
||||
return parameters.get(param - 1).getTypeName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameterClassName(int param) throws SQLException {
|
||||
return parameters.get(param - 1).getClassName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getParameterMode(int param) throws SQLException {
|
||||
return parameters.get(param - 1).getMode();
|
||||
}
|
||||
|
||||
public static class Parameter {
|
||||
|
||||
private int nullable;
|
||||
private boolean signed;
|
||||
private int mode;
|
||||
private String className;
|
||||
private int type;
|
||||
private String typeName;
|
||||
private int scale;
|
||||
private int precision;
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getNullable() {
|
||||
return nullable;
|
||||
}
|
||||
|
||||
public void setNullable(int nullable) {
|
||||
this.nullable = nullable;
|
||||
}
|
||||
|
||||
public boolean isSigned() {
|
||||
return signed;
|
||||
}
|
||||
|
||||
public void setSigned(boolean signed) {
|
||||
this.signed = signed;
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setMode(int mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public void setClassName(String className) {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
public void setTypeName(String typeName) {
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
public int getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
public void setScale(int scale) {
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public int getPrecision() {
|
||||
return precision;
|
||||
}
|
||||
|
||||
public void setPrecision(int precision) {
|
||||
this.precision = precision;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -41,9 +41,13 @@ import java.util.List;
|
||||
|
||||
public class MockPreparedStatement extends MockStatement implements PreparedStatement {
|
||||
|
||||
private final String sql;
|
||||
private final String sql;
|
||||
|
||||
private List<Object> parameters = new ArrayList<Object>();
|
||||
private final List<Object> parameters = new ArrayList<Object>();
|
||||
|
||||
private MockParameterMetaData metadata = new MockParameterMetaData();
|
||||
|
||||
private MockResultSetMetaData resultSetMetaData = new MockResultSetMetaData();
|
||||
|
||||
public MockPreparedStatement(Connection conn, String sql){
|
||||
super(conn);
|
||||
@@ -210,8 +214,7 @@ public class MockPreparedStatement extends MockStatement implements PreparedStat
|
||||
|
||||
@Override
|
||||
public ResultSetMetaData getMetaData() throws SQLException {
|
||||
|
||||
return null;
|
||||
return resultSetMetaData;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -241,7 +244,7 @@ public class MockPreparedStatement extends MockStatement implements PreparedStat
|
||||
|
||||
@Override
|
||||
public ParameterMetaData getParameterMetaData() throws SQLException {
|
||||
return null;
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user