未知的列' a'在'字段列表'

时间:2017-01-25 08:28:03

标签: java mysql prepared-statement

我整晚都在尝试这个

String querystate = " insert into provincias (Paises_idPais, Provincia, Abreviatura, Km2, Capital, `Ciudad mas grande`)"
                + " values (?, ?, ?, ?, ?, ?)";
PreparedStatement preparedStmt;
preparedStmt = conn.prepareStatement(querystate);
preparedStmt.setInt(1, cID);
preparedStmt.setString(2, sName);
preparedStmt.setString(3, sAbbr);
preparedStmt.setInt(4, sArea);
preparedStmt.setString(5, sCapital);
preparedStmt.setString(6, sLargest_city);

        preparedStmt.execute();

执行此操作时,它会给出一个如下所示的查询:

insert into provincias(Paises_idPais, Provincia, Abreviatura, Km2, Capital, `Ciudad mas grande`) values (1, `a`, `a`, 1, `a`, `a`)

Aaaaaa它给了我关于字段列表的错误

"未知列' a'在'字段列表'

这是我使用e.printStackTrace();

时得到的错误
com.mysql.jdbc.JDBC42PreparedStatement@202b0582:  insert into provincias (Paises_idPais, Provincia, Abreviatura, Km2, Capital, `Ciudad mas grande`) values (1, 'a', 'a', 1, 'a', 'a')

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 ''Ciudad mas grande') values (1, 'a', 'a', 1, 'a', 'a')' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.Util.getInstance(Util.java:408)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:943)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3970)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3906)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2524)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2677)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2549)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1192)
at DataAccess.DAOState.insertState(DAOState.java:38)
at Main.main(Main.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Sry for the spanish tables。

0 个答案:

没有答案