mardi 10 février 2015

why throw an oracle exception "ORA-00972: identifier is too long" in my java web project

The problem is when i call the function "importDBfromAllSheets.insertTables();" in my servlet, it will throw the "ORA-00972: identifier is too long".


But when i call the function in local main() function, it works well.


servlet code:



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");
}


and main() code:



public static void main(String[] args) {
ImportDBfromAllSheets importDBfromAllSheets = new ImportDBfromAllSheets(
GlobalVariables.oracleUrl, GlobalVariables.oracleUserName, GlobalVariables.oraclePassword);
importDBfromAllSheets.insertTables();
}


and my insertTables() is about:



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);


the exception is "pst.executeBatch();" threw.


It is strange that when i check the table in PL/SQL, it works well after i do main() function.





Aucun commentaire:

Enregistrer un commentaire