问题是,当我在servlet中调用函数importDBfromAllSheets.insertTables();
时,它将抛出"ORA-00972: identifier is too long"
。
但是当我在本地main()函数中调用该函数时,它运行良好。
servlet代码:
if (username != null && username.equals(GlobalVariables.defaultUserName)
&& password != null && password.equals(GlobalVariables.defaultPassword)) {
ImportDBfromAllSheets importDBfromAllSheets = new ImportDBfromAllSheets(
GlobalVariables.oracleUrl, GlobalVariables.oracleUserName, GlobalVariables.oraclePassword);
importDBfromAllSheets.insertTables();
System.out.println("aaaaaaaaaa");
response.getWriter().print("Updating...");
} else {
response.getWriter().print("User/Pwd error");
}
和main()代码:
public static void main(String[] args) {
ImportDBfromAllSheets importDBfromAllSheets = new ImportDBfromAllSheets(
GlobalVariables.oracleUrl, GlobalVariables.oracleUserName, GlobalVariables.oraclePassword);
importDBfromAllSheets.insertTables();
}
和我的insertTables()关于:
StringBuilder insert_sql = new StringBuilder();
StringBuilder subSql1 = new StringBuilder();
StringBuilder subSql2 = new StringBuilder();
List<String> columnNames = getColumnNames();
for (String columnName : columnNames) {
subSql1.append("\"").append(columnName).append("\",");
subSql2.append("?,");
}
String substring = subSql1.substring(0, subSql1.length() - 1);
String substring2 = subSql2.substring(0, subSql2.length() - 1);
insert_sql.append("insert into \"Complaints-All\" (")
.append(substring).append(") values (").append(substring2).append(")");
try {
con.setAutoCommit(false);
PreparedStatement pst = con.prepareStatement(insert_sql.toString());
for (List<String> row : rows.subList(1, rows.size())) {
for (int j = 0; j < columnNames.size(); j++) {
if (row.get(j).isEmpty())
pst.setNull(j + 1, Types.VARCHAR);
else
pst.setString(j + 1, row.get(j));
}
pst.addBatch();
}
pst.executeBatch();
con.commit();
System.out.println("Complaints-All: insert success!");
fileRename(path);
例外是“ pst.executeBatch();”扔。
奇怪的是,当我在PL / SQL中检查表时,在执行main()函数后它能很好地工作。
这是我的SQL:
insert into "Complaints-All" ("PR ID","Product","GE Knowledge Date","Comply code","Hazard.","Hazard - Lower Level.","Hazardous Situation.","SPCR Root Cause Code","Hazardous or Potentially Haz?","Regulatory Non-Compliance?","Modality Segment","Modality","Product Name","Product Line","Complaint Closure Code","Customer Country","RAC Product Line","RAC Product Name","SPC - System/Component Code","SPC - Problem Code","SPC - Correction Code","Further Investigation/Actions?","Additional Reportability Info","Subsystem","Symptom Code","Problem Code","Investigation Code","Division","PR State (AKA “State”)","Date Created","Date Closed","Device Identification Number","Complaint / Inv / CAPA Link","Customer's Issue Description","FE's Issue Desc (Editable)","Actions Taken/Rep's (Editable)","Closure Summary","Comments","Additional Info Requested","Parts Used","Software Version","Manufacturing Site","Model Number","SPCR Symptom Description","SPCR Problem Description","SPCR Resolution") select '10000143','Proteus','2012-11-30','','','','','','No','No','RAD','X-Ray','PROTEUS','PROTEUS XR/A','Low impact - Further Investigation not required','USA','','','XP','E1','PZ','No Further Investigation Needed (Investigation is','This complaint is not a hazardous situation, nor is it expected to result in harm to a patient, operator or other user. In accordance with GEHC Post Market Procedures, regulatory reporting for this event is not required because this event: 1) Did not result in a death. 2) Does not represent a serious threat to public health. 3) Did not result in a serious injury, serious illness, serious deterioration in the state of health or other serious harm. 4) The potential for death or serious injury to result from reoccurrence is considered to be remote based on the analysis above. 5) Has not led to a corrective action to prevent death or serious injury. 6) Did not involve a counterfeit product. 7) Did not cause fetal risk or result in congenital abnormality or birth defect. 8) Did not result in an accidental radiation occurrence nor was a Notification of Defect/Failure to Comply.','','','','','Diagnostic Imaging (DI)','Low Impact - Closed','2012-12-19','2012-12-22','706632PRO','','console display blank','12/19/2012 03:13 AM (GMT) added by TrackwiseService Production (PID-000006): console display blank ','12/19/2012 03:13 AM (GMT) added by TrackwiseService Production (PID-000006): 005~msa maintenance ~MODEL# ~SERIAL# ~PATIENT IMPACT ====> no patient involved. ~DIAGNOSIS/TROUBLESHOOTING ====> ac/dc fuse defective. defective lvps. ~REPAIR/CALIBRATION ====> replaced fuse and lsps brd.performed a reboot. system bootedup successfully. performed a test acquisition. acquisition successfully completed. ','','','','2348721|5126988-2|99185290','','GE Hangwei Medical Systems Co','','','','' from dual where not exists(select "PR ID" from "Complaints-All" where ("PR ID"='10000143'))
我在PL / SQL中执行此sql后没有错误,但在Java "java.sql.SQLException: ORA-00972: identifier is too long"
中也引发了异常。
只是一个猜测。
检查您的insert_sql.toString()
。看起来您在列名之前或名称中间有一些多余的“ char”,因此DB在列名中包括了所有之后的文本。或者相反,您错过了关闭“ char。]
像insert into my_table ("my column), values ("aaaa");