为什么抛出oracle异常;ORA-00972:标识符太长“;在我的java web项目中

为什么抛出oracle异常;ORA-00972:标识符太长“;在我的java web项目中,java,oracle,servlets,web,Java,Oracle,Servlets,Web,问题是当我调用函数importDBfromAllSheets.insertTables()时在我的servlet中,它将抛出“ORA-00972:标识符太长” 但是当我在local main()函数中调用该函数时,它工作得很好 servlet代码: if (username != null && username.equals(GlobalVariables.defaultUserName) && password != null &

问题是当我调用函数
importDBfromAllSheets.insertTables()时
在我的servlet中,它将抛出
“ORA-00972:标识符太长”

但是当我在local 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()代码:

我的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);
在PL/sql中执行此sql后没有错误,但在java中也抛出异常
“java.sql.SQLException:ORA-00972:标识符太长”

只是猜测而已

检查您的
insert\u sql.toString()
。看起来您在列名之前或名称中间有一些额外的“char”,因此DB会在列名中包含后面的所有文本。或者相反,您错过了关闭“char”


插入我的表(“我的列”),值(“aaaa”);

“所有投诉:更新成功!在我的main()函数return中,进程以退出代码0“结束,因此,我认为insertTables()是有效的,当我将其复制到PL/sql并执行时,insert\U sql是正确的。打印生成的sql语句(insert\U sql的内容)并将其发布到此处。请显示您的ddl。您认为“我在PL/sql中执行此sql”是什么意思“您能告诉我们在哪里使用这个存储过程吗?在哪一行抛出异常?可能是字符集问题。可能由于转换为Oracle使用的字符集编码,Java字符串中正确表示的某些符号在传递给Oracle时会变成两个符号。@Jens:这不是“标识符太长”的意思。
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);
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'))