根据该响应,我从SAP获取数据更新MYSQL DB表中的标志。但我的查询每次都给我一个错误。 JAVA和SAP之间的连接是可以的。我可以将数据发送到SAP。这是工作。
这是我的方法。
private void tableOparator(Table table) throws Exception {
pooler = DBPool_POSMS.getInstance();
dataSource = pooler.getDataSource();
Connection con = dataSource.getConnection();
con.setAutoCommit(false);
qex = new DBTableQueryExcecutre(con);
for (int i = 0; i < table.getNumRows(); i++) {
table.setRow(i);
String sbQuery2 = "update tbl_po_data set status = 'X' where reference_no " + " in (SELECT REFNO from '"
+ table.getName() + "' where FLAG = 'X')";
int rcount = qex.runQuery(sbQuery2);
System.out.println("tbl_po_data Rows -->" + rcount + "Status Updated");
con.commit();
}
qex.closeConnections();
}
我的LOGCAT
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''ZSLPOSMSTBL' where FLAG = 'X')' at line 1
at sun.reflect.GeneratedConstructorAccessor1.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4120)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4052)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2503)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2664)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2809)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1811)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1725)
at org.apache.commons.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:228)
at org.apache.commons.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:228)
at DBTableQueryExcecutre.runQuery(DBTableQueryExcecutre.java:52)
at CreatePO.tableOparator(CreatePO.java:203)
at CreatePO.sendDataToSap(CreatePO.java:170)
at CreatePO.run(CreatePO.java:53)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)
答案 0 :(得分:0)
您正在尝试从字符串值中进行选择
'ZSLPOSMSTBL'
代替您的表名ZSLPOSMSTBL
删除SQL语句中的引号,它应该可以工作。
"update tbl_po_data set status = 'X' where reference_no " + " in (SELECT REFNO from "
+ table.getName() + " where FLAG = 'X');"