代碼如下:
public class TEST implements Extractable {
private String getSqlStr() {
StringBuffer buf = new StringBuffer();
buf.append(" SELECT nvl(ROUND(J.AMOUNT),’0’) AS SHIHARAIKIN1, ");
buf.append(" FROM T_WL_TAX_PRINCIPAL J ");
return buf.toString();
}
private List<Map> execQuery() {
PreparedStatement ps = null;
ResultSet rs = null;
DBean db = new DBean();
List<Map> resultList = new LinkedList<Map>();
Connection con = null;
try {
db.connect();
con = db.getConnection();
ps = con.prepareStatement(getSqlStr());
rs = ps.executeQuery();
int i = 0;
while (rs.next()) {
Map<String, String> mapData = new HashMap<String, String>();
int ShiHaRaiKin = Integer.valueOf(rs.get("SHIHARAIKIN1"));
}
}
} catch (Exception e) {
resultList.add(mapData);
} finally {
DBean.closeAll(null, ps, db);
}
return resultList;
}
}
在 int ShiHaRaiKin = Integer.valueOf(rs.get("SHIHARAIKIN1")); 語句的時候報出下面錯誤:
For input string at java.lang.NumberFormatException.forInputString(Unknown Source)
我試過在rs.get("SHIHARAIKIN1")後面加個trim方法,還是會出這個錯誤,求高手指導~~~~~~~~
你的select語句中“SHIHARAIKIN1,”為什麼要有個","號啊?