每当我在mySQL中运行以下语法时:
com.mysql.jdbc.PreparedStatement@4f2f19fd: INSERT INTO Matches_2016_Qualification (Additional_information, Team_number, Points, Auton, Match_number) VALUES (NONE, 4602, 100, 0, 1)
我收到以下错误:
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'NONE' in 'field list'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1604)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1519)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1504)
at me.whereisthemonkey.ScoutingInformation.GUI.Matches.addMatch(Matches.java:236)
at me.whereisthemonkey.ScoutingInformation.GUI.MainGUI$1.actionPerformed(MainGUI.java:73)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
这没有任何意义,因为NONE甚至不是一个列......我可以有一个损坏的数据库吗? 我是否需要将NONE声明为\" NONE \"或作为另一种类型?
感谢您的帮助, 卢卡斯
答案 0 :(得分:5)
NONE
在MySQL中没有任何意义。错误信息只是说“我不认识”没有“,所以我认为这是一个列名,而不是”。
也许您的意思是以下之一:
VALUES ('NONE', 4602, 100, 0, 1)
VALUES (NULL, 4602, 100, 0, 1)
VALUES (DEFAULT, 4602, 100, 0, 1)
第一个将字符串'NONE'
插入字段;第二个NULL
值,第三个插入默认值(如果没有定义,则为NULL
)。
答案 1 :(得分:0)
您的错误:“字段列表”中的未知列“无”
将此代码放在变量中,例如
Str = INSERT INTO Matches_2016_Qualification(Additional_information,Team_number,Points,Auton,Match_number)VALUES(NONE,4602,100,0,1)
然后运行到你的mysql命令行并给我们结果。
你的NONE数据类型是什么?