英文:
I' m getting error in java.sql.BatchUpdateException: ORA-00917: missing comma
问题
// Statement stmt=con.createStatement();
String SQL = "insert into JMX(MAXThreads number(10),currentThreadCount number(10),MaxkeepAliveRequest number(10),threadPriority number(10), maxTime number(10),requestCount number(10),bytesReceived number(10),bytesSent number(10),processingTime number(10),modelerType varchar2(50) ,errorCount number(10)) values (?,?,?,?,?,?,?,?,?,?,?)";
try (PreparedStatement pst=con.prepareStatement(SQL)) {
pst.setObject(1, memoryMbean);
pst.setObject(2, osMbean);
pst.setObject(3, tmMbean);
pst.setObject(4, smMbean);
pst.setObject(5, grpMbean);
pst.setObject(6, grpMbean1);
pst.setObject(7, grpMbean2);
pst.setObject(8, grpMbean3);
pst.setObject(9, grpMbean4);
pst.setObject(10, grpMbean5);
pst.setObject(11, grpMbean6);
pst.addBatch();
pst.setObject(1, memoryMbean);
pst.setObject(2, osMbean);
pst.setObject(3, tmMbean);
pst.setObject(4, smMbean);
pst.setObject(5, grpMbean);
pst.setObject(6, grpMbean1);
pst.setObject(7, grpMbean2);
pst.setObject(8, grpMbean3);
pst.setObject(9, grpMbean4);
pst.setObject(10, grpMbean5);
pst.setObject(11, grpMbean6);
pst.executeBatch();
con.commit();
// JOptionPane.showMessageDialog(null,"Done");
} catch (SQLException e) {
e.printStackTrace();
}
这是我得到的输出:
START
java.sql.BatchUpdateException: ORA-00917: missing comma
PROCESS COMPLETED
at oracle.jdbc.driver.OraclePreparedStatement.executeLargeBatch(OraclePreparedStatement.java:9711)
at oracle.jdbc.driver.T4CPreparedStatement.executeLargeBatch(T4CPreparedStatement.java:1447)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:9487)
at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:237)
at com.jmx.Connection2.waitMethod(Connection2.java:304)
at com.jmx.Connection2.main(Connection2.java:173)
英文:
// Statement stmt=con.createStatement();
String SQL = "insert into JMX(MAXThreads number(10),currentThreadCount number(10),MaxkeepAliveRequest number(10),threadPriority number(10), maxTime number(10),requestCount number(10),bytesReceived number(10),bytesSent number(10),processingTime number(10),modelerType varchar2(50) ,errorCount number(10)) values (?,?,?,?,?,?,?,?,?,?,?)";
try (PreparedStatement pst=con.prepareStatement(SQL)) {
pst.setObject(1, memoryMbean);
pst.setObject(2, osMbean);
pst.setObject(3, tmMbean);
pst.setObject(4, smMbean);
pst.setObject(5, grpMbean);
pst.setObject(6, grpMbean1);
pst.setObject(7, grpMbean2);
pst.setObject(8, grpMbean3);
pst.setObject(9, grpMbean4);
pst.setObject(10, grpMbean5);
pst.setObject(11, grpMbean6);
pst.addBatch();
pst.setObject(1, memoryMbean);
pst.setObject(2, osMbean);
pst.setObject(3, tmMbean);
pst.setObject(4, smMbean);
pst.setObject(5, grpMbean);
pst.setObject(6, grpMbean1);
pst.setObject(7, grpMbean2);
pst.setObject(8, grpMbean3);
pst.setObject(9, grpMbean4);
pst.setObject(10, grpMbean5);
pst.setObject(11, grpMbean6);
pst.executeBatch();
con.commit();
// JOptionPane.showMessageDialog(null,"Done");
} catch (SQLException e) {
e.printStackTrace();
}
This is my output im getting:
START
java.sql.BatchUpdateException: ORA-00917: missing comma
PROCESS COMPLETED
at oracle.jdbc.driver.OraclePreparedStatement.executeLargeBatch(OraclePreparedStatement.java:9711)
at oracle.jdbc.driver.T4CPreparedStatement.executeLargeBatch(T4CPreparedStatement.java:1447)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:9487)
at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:237)
at com.jmx.Connection2.waitMethod(Connection2.java:304)
at com.jmx.Connection2.main(Connection2.java:173)
答案1
得分: 1
你不需要指定类型,移除列类型:
"insert into JMX(MAXThreads, currentThreadCount, MaxkeepAliveRequest,
threadPriority, maxTime, requestCount, bytesReceived, bytesSent,
processingTime, modelerType, errorCount) values (?,?,?,?,?,?,?,?,?,?,?)";
另外,在调用addBatch之后为什么要再次设置值(重复设置)?
英文:
You don't need to specify the types, remove the columns types:
"insert into JMX(MAXThreads , currentThreadCount , MaxkeepAliveRequest
, threadPriority , maxTime , requestCount , bytesReceived , bytesSent
, processingTime , modelerType , errorCount ) values (?,?,?,?,?,?,?,?,?,?,?)";
Also why are you setting values again (duplicate) after addBatch?
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论