日期:2014-05-18 浏览次数:20778 次
String StrSql ="insert into mem_server (id,typeid,ip,community) values ('?','?','?','?')";
String [] aStrParams = new String[4];
aStrParams[0] = (inMap.get("A")).replaceAll(" ", "");
aStrParams[1] = (inMap.get("B")).replaceAll(" ", "");
aStrParams[2] = (inMap.get("C")).replaceAll(" ", "");
aStrParams[3] = (inMap.get("D")).replaceAll(" ", "");
sqlvisit.UpdateSQL(StrSql, aStrParams);
public int UpdateSQL(String sSQL, String[] sParams) {
int result = 0;
try {
PreparedStatement ps = _CONN.prepareStatement(sSQL);
if (sParams != null) {
for (int i = 0; i < sParams.length; i++) {
ps.setString(i + 1, sParams[i]);
}
}
result = ps.executeUpdate();
} catch (Exception ex) {
ex.printStackTrace();
System.out.println(ex.getMessage());
} finally {
//CloseConn();
}
return result;
}
values ('?','?','?','?')改为
values (?,?,?,?)之后程序虽然不报错了,但是数据库中却没有输入进去。