Java 无法创建配置文件com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的SQL语法有错误;

Java 无法创建配置文件com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的SQL语法有错误;,java,mysql,jdbc,Java,Mysql,Jdbc,我正在创建简单数据库,下面是我的数据库模式: create database studentapp_db ; create table students_info ( regno int(10) not null, firstname varchar (50) , middlename varchar (50), lastname varchar (50), primary key(regno) ) ; create table gaurdian_info ( regno int(10)

我正在创建简单数据库,下面是我的数据库模式:

create  database studentapp_db ;
create table  students_info
( regno int(10) not null,
firstname varchar (50) ,
middlename varchar (50),
lastname varchar (50),
primary key(regno) ) ;

create table  gaurdian_info
( regno int(10) not null,
gfirstname varchar (50) ,
gmiddlename varchar (50),
glastname varchar (50),
primary key(regno) ) ;

create table  students_otherinfo
( regno int(10) not null,
 isadmin varchar (1) ,
passowrd varchar (50),
primary key(regno) ) ;
现在,我正在从运行配置中插入值,但这给了我这种错误

 unable to create the profile
 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 '10,'AAYUSH','KUMAR','NA')' at line 1
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at                                                                       
 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(UnknownSource)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3515)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3447)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1951)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2554)
at    
 com.mysql.jdbc.PreparedStatement.executeInternal
(PreparedStatement.java:1761)
 at com.mysql.jdbc.PreparedStatement.executeUpdate
(PreparedStatement.java:2046)
at com.mysql.jdbc.PreparedStatement.executeUpdate
(PreparedStatement.java:1964)
at com.mysql.jdbc.PreparedStatement.executeUpdate
(PreparedStatement.java:1949)
at com.jspider.jdbc.common.Transactionplusassignmentexample.main
(Transactionplusassignmentexample.java:35)
下面是我的java代码:

 package com.jspider.jdbc.common;

 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import com.mysql.jdbc.Driver;

 public class Transactionplusassignmentexample {

 public static void main(String[] args) {

    java.sql.Connection con = null;
    PreparedStatement pstmt1 = null;
    PreparedStatement pstmt2 = null;
    PreparedStatement pstmt3 = null;

    //1 load DB driver
    try {
        Driver driverRef = new Driver();
        DriverManager.registerDriver(driverRef);


    //2 Get DB connection via driver

        String dbUrl = "jdbc:mysql://localhost:3306                     
        /Studentapp_db?user=j2ee&password=j2ee";
        con = DriverManager.getConnection(dbUrl);

    //3. Issue sql queries via connection   
        String query1 = "insert into Students_info" + "values(?,?,?,?)" ;
        pstmt1 = con.prepareStatement(query1);
        pstmt1.setInt(1,Integer.parseInt(args[0]));
        pstmt1.setString(2,args[1]);
        pstmt1.setString(3,args[2]);
        pstmt1.setString(4,args[3]);
        int count1 =pstmt1.executeUpdate();

        String query2 = "insert into guardian_info" + "values(?,?,?,?)" ;
        pstmt2 = con.prepareStatement(query2);
        pstmt2.setInt(1,Integer.parseInt(args[0]));
        pstmt2.setString(2,args[4]);
        pstmt2.setString(3,args[5]);
        pstmt2.setString(4,args[6]);
        int count2 =pstmt2.executeUpdate();


        String query3 = "insert into Students_otherinfo" + 
        "values(?,?,?,)" ;
        pstmt3 = con.prepareStatement(query3);
        pstmt3.setInt(1,Integer.parseInt(args[0]));
        pstmt3.setString(2,args[7]);
        pstmt3.setString(3,args[8]);
        int count3 =pstmt3.executeUpdate();

    //4 Process the results
        System.out.println("Profile created sucessfully");
        System.out.println("row affected for S_I:"+count1);
        System.out.println("row affected for G_I:"+count2);
        System.out.println("row affected for S_OI:"+count3);





    } catch (SQLException e) {
        System.err.println("unable to create the profile");
        e.printStackTrace();
    }finally {

        //close all jdbc object
        //close all 3 preparedstatement object

        try
        { if (con!= null){
            con.close();
        }
        if (pstmt1!= null){
            pstmt1.close();
        }
         if(pstmt2!= null){
             pstmt2.close();
         }
         if(pstmt3!= null){
             pstmt3.close();
         }
        }
        catch( SQLException e) {
            e.printStackTrace();

        }//end of outside class try catch
        } 

        } 

        }
请帮助我了解java

在“学生信息”和“价值观”之间添加空格

而不是

String query3 = "insert into Students_otherinfo" + 
    "values(?,?,?,)" ;
并删除额外的“,”:

编辑:评论后


并用高尔迪安取代了《守护者》,就像《夏姆》中的那样。或者更改模式(更好).

thanx@Daminox但即使在给空间后,我也会遇到一些其他错误。这是一个新错误,我无法创建配置文件com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxErrorRexception:表'studentapp\u db.guardian\u info'不存在这是另一个错误,在您的模式中,可以随意用gaurdian替换guardian:D
String query3 = "insert into Students_otherinfo" + 
    "values(?,?,?,)" ;
 String query3 = "insert into Students_otherinfo " + 
    "values(?,?,?)" ;