我的目标是向我创建的现有表添加一个新行.但是,我收到以下错误.
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的SQL语法中有错误; 检查与MySQL服务器版本对应的手册,以便在sun.reflect的第1行使用"姓名,姓氏,电话号码"附近的VALUES(2056732,'Hello','World',3). sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)中的NativeConstructorAccessorImpl.newInstance0(Native Method)位于sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45),位于java.lang.reflect.Constructor.newInstance(构造函数. java:408)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:1053)在com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4074)的com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4006)com.mysql.jdbc.MysqlIO.sendCommand( MysqlIO.java:2468)com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2629)com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2719)at com.my sql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)位于com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2450)的com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2371)at com AddingNewRow.main中的.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2355)(AddingNewRow.java:50)
这是代码的一部分.如果您需要整个代码以便找出问题所在,请告诉我.
Connection conn = null;
PreparedStatement ps = null;
Scanner in = new Scanner(System.in);
System.out.print("Enter the student number: ");
int studentNO = in.nextInt();
System.out.print("Enter the first name: ");
String fName = in.next();
System.out.print("Enter the last name: ");
String lName = in.next();
System.out.print("Enter the telephone number: ");
int telNO = in.nextInt();
try {
conn = DriverManager.getConnection(CONN_STRING, USERNAME, PASSWORD);
System.out.println("Connected");
//Executing a query
String sql_query = "INSERT INTO …Run Code Online (Sandbox Code Playgroud)