mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor
This commit is contained in:
@@ -22,7 +22,6 @@ import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.StringWriter;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URL;
|
||||
import java.sql.Connection;
|
||||
import java.sql.Date;
|
||||
@@ -43,7 +42,6 @@ import java.util.Properties;
|
||||
|
||||
import com.alibaba.druid.logging.Log;
|
||||
import com.alibaba.druid.logging.LogFactory;
|
||||
import com.alibaba.druid.mapping.DruidMappingException;
|
||||
|
||||
/**
|
||||
* @author wenshao<szujobs@hotmail.com>
|
||||
@@ -595,7 +593,7 @@ public final class JdbcUtils {
|
||||
Map<String, Object> row = new LinkedHashMap<String, Object>();
|
||||
|
||||
for (int i = 0, size = rsMeta.getColumnCount(); i < size; ++i) {
|
||||
String columName = rsMeta.getColumnName(i + 1);
|
||||
String columName = rsMeta.getColumnLabel(i + 1);
|
||||
Object value = rs.getObject(i + 1);
|
||||
row.put(columName, value);
|
||||
}
|
||||
@@ -612,33 +610,7 @@ public final class JdbcUtils {
|
||||
|
||||
private static void setParameters(PreparedStatement stmt, List<Object> parameters) throws SQLException {
|
||||
for (int i = 0, size = parameters.size(); i < size; ++i) {
|
||||
Object val = parameters.get(i);
|
||||
int paramIndex = i + 1;
|
||||
|
||||
if (val == null) {
|
||||
stmt.setNull(paramIndex, Types.VARCHAR);
|
||||
} else if (val instanceof BigDecimal) {
|
||||
stmt.setBigDecimal(paramIndex, (BigDecimal) val);
|
||||
} else if (val instanceof String) {
|
||||
stmt.setString(paramIndex, (String) val);
|
||||
} else if (val instanceof Date) {
|
||||
long time = ((Date) val).getTime();
|
||||
stmt.setTimestamp(paramIndex, new java.sql.Timestamp(time));
|
||||
} else if (val instanceof Byte) {
|
||||
stmt.setByte(paramIndex, (Byte) val);
|
||||
} else if (val instanceof Short) {
|
||||
stmt.setShort(paramIndex, (Short) val);
|
||||
} else if (val instanceof Integer) {
|
||||
stmt.setInt(paramIndex, (Integer) val);
|
||||
} else if (val instanceof Long) {
|
||||
stmt.setLong(paramIndex, (Long) val);
|
||||
} else if (val instanceof Float) {
|
||||
stmt.setFloat(paramIndex, (Float) val);
|
||||
} else if (val instanceof Double) {
|
||||
stmt.setDouble(paramIndex, (Double) val);
|
||||
} else {
|
||||
throw new DruidMappingException("not support parameters : " + val);
|
||||
}
|
||||
stmt.setObject(i + 1, parameters.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user