/**
* 获取数据库中字段类型,转换成jdbc类型
* @param rst resultset
* @param rolumnDbClass 数据类型
* @param i
* @return
* @throws SQLException
*/
public static String typeValue(ResultSet rst, String rolumnDbClass,int i) throws SQLException{
String value = null;
if("date".equals(rolumnDbClass)
|| "datetime".equals(rolumnDbClass)){
value = String.valueOf(rst.getDate(i));
}else if ("varchar".equals(rolumnDbClass)
|| "char".equals(rolumnDbClass)){
value = rst.getString(i);
}else if("float".equals(rolumnDbClass)){
value = String.valueOf(rst.getDouble(i));
}else if("decimal".equals(rolumnDbClass)){
value = String.valueOf(rst.getBigDecimal(i));
}else if ("smallint".equals(rolumnDbClass)){
value = String.valueOf(rst.getShort(i));
}
else if ("int".equals(rolumnDbClass)){
value = String.valueOf(rst.getInt(i));
}
return value;
}
while(rst.next()){
count++;
StringBuffer sb = new StringBuffer();
for(int i=1 ;i<=tableLength ;i++){
//获取数据库类型
String rolumnDbClass = rsmd.getColumnTypeName(i);
value = typeValue(rst, rolumnDbClass, i);
if(i==tableLength){
sb.append("'").append(CommonUtils.conValue(value)).append("'");
}else
sb.append("'").append(CommonUtils.conValue(value)).append("',");
//获取数据库中字段类型,转换成jdbc类型
if("date".equals(rolumnDbClass)
|| "datetime".equals(rolumnDbClass)){
value = String.valueOf(rst.getDate(i));
}else if ("varchar".equals(rolumnDbClass)
|| "char".equals(rolumnDbClass)){
value = rst.getString(i);
}else if("float".equals(rolumnDbClass)){
value = String.valueOf(rst.getDouble(i));
}else if("decimal".equals(rolumnDbClass)){
value = String.valueOf(rst.getBigDecimal(i));
}else if ("smallint".equals(rolumnDbClass)){
value = String.valueOf(rst.getShort(i));
}
else if ("int".equals(rolumnDbClass)){
value = String.valueOf(rst.getInt(i));
}
/* //获取数据库类型与java相对于的类型
String rolumnClass = rsmd.getColumnClassName(i);
System.out.println("java对应:"+rolumnClass); */
//获取列名
String columnName = rsmd.getColumnName(i);
// System.out.println("获取列名:"+columnName);
}
log.debug(count+" : "+sb);
}