mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
修正encodingFilter,兼容SimpleDriver
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@430 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -116,19 +116,83 @@ public class EncodingConvertFilter extends FilterAdapter {
|
||||
|
||||
@Override
|
||||
public Object resultSet_getObject(FilterChain chain, ResultSetProxy result, int columnIndex, java.util.Map<String, Class<?>> map) throws SQLException {
|
||||
Object value = super.resultSet_getObject(chain, result, columnIndex, map);
|
||||
ResultSet rawResultSet = result.getResultSetRaw();
|
||||
ResultSetMetaData metadata = rawResultSet.getMetaData();
|
||||
int columnType = metadata.getColumnType(columnIndex);
|
||||
|
||||
Object value = null;
|
||||
switch (columnType) {
|
||||
case Types.CHAR:
|
||||
value = super.resultSet_getString(chain, result, columnIndex);
|
||||
break;
|
||||
case Types.CLOB:
|
||||
value = super.resultSet_getString(chain, result, columnIndex);
|
||||
break;
|
||||
case Types.LONGVARCHAR:
|
||||
value = super.resultSet_getString(chain, result, columnIndex);
|
||||
break;
|
||||
case Types.VARCHAR:
|
||||
value = super.resultSet_getString(chain, result, columnIndex);
|
||||
break;
|
||||
default:
|
||||
value = super.resultSet_getObject(chain, result, columnIndex, map);
|
||||
}
|
||||
|
||||
return decodeObject(result.getStatementProxy().getConnectionProxy(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resultSet_getObject(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException {
|
||||
Object value = super.resultSet_getObject(chain, result, columnLabel);
|
||||
ResultSet rawResultSet = result.getResultSetRaw();
|
||||
ResultSetMetaData metadata = rawResultSet.getMetaData();
|
||||
int columnIndex = rawResultSet.findColumn(columnLabel);
|
||||
int columnType = metadata.getColumnType(columnIndex);
|
||||
|
||||
Object value = null;
|
||||
switch (columnType) {
|
||||
case Types.CHAR:
|
||||
value = super.resultSet_getString(chain, result, columnLabel);
|
||||
break;
|
||||
case Types.CLOB:
|
||||
value = super.resultSet_getString(chain, result, columnLabel);
|
||||
break;
|
||||
case Types.LONGVARCHAR:
|
||||
value = super.resultSet_getString(chain, result, columnLabel);
|
||||
break;
|
||||
case Types.VARCHAR:
|
||||
value = super.resultSet_getString(chain, result, columnLabel);
|
||||
break;
|
||||
default:
|
||||
value = super.resultSet_getObject(chain, result, columnLabel);
|
||||
}
|
||||
return decodeObject(result.getStatementProxy().getConnectionProxy(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resultSet_getObject(FilterChain chain, ResultSetProxy result, String columnLabel, java.util.Map<String, Class<?>> map) throws SQLException {
|
||||
Object value = super.resultSet_getObject(chain, result, columnLabel, map);
|
||||
ResultSet rawResultSet = result.getResultSetRaw();
|
||||
ResultSetMetaData metadata = rawResultSet.getMetaData();
|
||||
int columnIndex = rawResultSet.findColumn(columnLabel);
|
||||
int columnType = metadata.getColumnType(columnIndex);
|
||||
|
||||
Object value = null;
|
||||
switch (columnType) {
|
||||
case Types.CHAR:
|
||||
value = super.resultSet_getString(chain, result, columnLabel);
|
||||
break;
|
||||
case Types.CLOB:
|
||||
value = super.resultSet_getString(chain, result, columnLabel);
|
||||
break;
|
||||
case Types.LONGVARCHAR:
|
||||
value = super.resultSet_getString(chain, result, columnLabel);
|
||||
break;
|
||||
case Types.VARCHAR:
|
||||
value = super.resultSet_getString(chain, result, columnLabel);
|
||||
break;
|
||||
default:
|
||||
value = super.resultSet_getObject(chain, result, columnLabel, map);
|
||||
}
|
||||
|
||||
return decodeObject(result.getStatementProxy().getConnectionProxy(), value);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user