在GetModifiedXMLDataFrom.main(GetModifiedXMLDataFrom.java:339) 我收到此错误,即使我有16个字段和16个?不知道为什么会出现错误。它因为preparedStmt.setString(15,“1”); 但它正处于其中一种状态,因此它达到了预期的目的。
任何帮助都很受欢迎,提前致谢。
String strInsertQuery = " UPDATE `cve_data` SET `CVE_ID`=?,
`CVE_DESCRIPTION`=?, `CVE_SEVERITY`=?, `CVE_PRODUCT_NAME`=?,
`CVE_PRODUCT_VERSION`=?, `CVE_VENDOR_NAME`=?, `CVE_PUBLISHED`=?,
`CVE_MODIFIED`=?, `CVSS_VERSION`=?, `CVSS_SCORE`=?,
`CVSS_BASE_SCORE`=?, `CVSS_IMPACT_SUBSCORE`=?,
`CVSS_EXPLOIT_SUBSCORE`=?, `CVSS_VECTOR`=?, `CVE_ASSESSED`=?
where `CVE_ID`=? ";
PreparedStatement preparedStmt = con.prepareStatement(strInsertQuery);
Calendar calendar = Calendar.getInstance();
java.sql.Date tempDate = new java.sql.Date(calendar.getTime().getTime());
while (itrCVEData.hasNext()) {
hmCVEInsData = (HashMap)itrCVEData.next();
preparedStmt.setString (1, (String)hmCVEInsData.get("CVEName")); //done
preparedStmt.setString (2, (String)hmCVEInsData.get("CVEDescr")); //done
preparedStmt.setString (3, (String)hmCVEInsData.get("CVESeverity")); //done
preparedStmt.setString (4, (String)hmCVEInsData.get("CVEProductname"));//done
preparedStmt.setString (5, (String)hmCVEInsData.get("CVEProductVersion"));//done
preparedStmt.setString (6, (String)hmCVEInsData.get("CVEProductvendor"));//done
if (hmCVEInsData.get("CVEPublished") != null) {
preparedStmt.setDate (7, tempDate.valueOf((String)hmCVEInsData.get("CVEPublished")));//done
} else {
preparedStmt.setDate (7, null);
}
if (hmCVEInsData.get("CVEModified") != null) {
preparedStmt.setDate (8, tempDate.valueOf((String)hmCVEInsData.get("CVEModified")));//done
} else {
preparedStmt.setDate (8, null);
}
preparedStmt.setString (9, (String)hmCVEInsData.get("CVECVSSversion"));//done
preparedStmt.setString (10, (String)hmCVEInsData.get("CVECVSSscore"));//done
preparedStmt.setString (11, (String)hmCVEInsData.get("CVECVSSbasescore"));//done
preparedStmt.setString (12, (String)hmCVEInsData.get("CVECVSSimpactsubscore"));//done
preparedStmt.setString (13, (String)hmCVEInsData.get("CVECVSSexploitsubscore"));//done
preparedStmt.setString (14, (String)hmCVEInsData.get("CVECVSSvector"));//done
//3 condition code starts here
String str = (String)hmCVEInsData.get("CVECVSSscore");
//String strCVEID = (String)hmCVEInsData.get("CVEName");
//fill null values with empty strings
if(str.equals("")){
str = "0.0";
}
String flag = "0";
//preparedStmt.setString (15, flag);
//convert string to double
double fNum = Double.parseDouble(str);
if ( fNum >= CVSS_2_Critical_Base || fNum >= CVSS_3_Critical_Base){
String strCVEID = (String)hmCVEInsData.get("CVEName");
//System.out.println(strCVEID);
if(strCVEID.contains("2018")){
System.out.println(strCVEID);
String strSelectQuery = "SELECT * FROM `cve_data` where `CVE_ID` ='" +strCVEID+ "' ";
preparedStmt = null;
preparedStmt = con.prepareStatement(strSelectQuery);
ResultSet rs = preparedStmt.executeQuery();
while ( rs.next() ) {
String srtrCVSSSCORE = rs.getString("CVSS_SCORE");
System.out.println(srtrCVSSSCORE);
String strTISeverity = rs.getString("CVE_TI_SEVERITY");
System.out.println(strTISeverity);
double fNum2 = Double.parseDouble(srtrCVSSSCORE);
if ( fNum2 >= fNum ){
System.out.println("Inside the loop");
preparedStmt.setString (15, flag);
}
else
{
System.out.println("Inside the Else");
preparedStmt.setString (15, "1");
}
}
}
}
//3 condition code ends here
preparedStmt.setString (16, (String)hmCVEInsData.get("CVEName"));//done
preparedStmt.execute();
}