我能夠連接到數據庫,但在執行preparedStatement插入值時遇到異常。我可以使用工作臺使用MySQL表訪問表,並從那裏插入值。表格的拼寫是正確的。使用JDBC連接到MySQL時存在SQL語法錯誤,表示該表不存在。 (但表格存在))
String insertTableSQL = "INSERT INTO source_domain_english_OY2_Jul2014(filename, seed, words, frequency, type, after_before) VALUES(?,?,?,?,?,?)";
.
.
.
.
preparedStatement.executeUpdate();
我已張貼下面
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'm_r.source_domain_english_OY2_Jul2014' doesn't exist
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
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:1052)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2002)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2624)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2127)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2427)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2345)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2330)
at edu.albany.ils.remnd.balancedcorpus.english.GramsSearch.readPatterns(GramsSearch.java:948)
at edu.albany.ils.remnd.balancedcorpus.english.GramsSearch.main(GramsSearch.java:45)
你確定你在兩種情況下都使用'm_r'數據庫嗎? –
您是否嘗試在輸出窗口中輸出查詢,如下面的'System.out.println(「Checking Prepared Statement:」+ preparedStatement);'然後嘗試在MySQL工作臺上運行以查看您是否收到錯誤? – John
同意檢查模式(用戶)是否相同 – Kode