Java (当我输入input';(2,we,we,2,30.0)';时,我出现错误com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:

Java (当我输入input';(2,we,we,2,30.0)';时,我出现错误com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:,java,mysql,mysql-error-1064,Java,Mysql,Mysql Error 1064,当我输入输入“(2,we,we,2,30.0)”时,我有一个错误,它被称为语法错误。我相信错误来自create table,但无法识别错误 以下是创建表的代码: public boolean addFlight(Flight flightObj) { Statement st; try { st = DB.getConnection().createStatement(); St

当我输入输入“(2,we,we,2,30.0)”时,我有一个错误,它被称为语法错误。我相信错误来自create table,但无法识别错误

以下是创建表的代码:

public  boolean addFlight(Flight flightObj)
    {
        Statement st;
        try {
            st = DB.getConnection().createStatement();
        
        
        String str= "INSERT INTO flight table ("+flightObj.getFlightId()+","+flightObj.getSource()+","+flightObj.getDestination()+","
                     +flightObj.getNoOfSeats()+","+flightObj.getFlightFare()+")";
                            
        try {
            int rowsInserted = st.executeUpdate(str);
            
            if(rowsInserted >0)
            {
                return true;
            }
            
            else
            {
                return false;
            }
下面是错误代码:我想可能是CREATETABLE方法引起的错误

hu Sep 10 10:28:56 SGT 2020 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

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 '(2,we,we,2,30.0)' at line 1
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:403)
    at com.mysql.jdbc.Util.getInstance(Util.java:386)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:944)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3933)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3869)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2524)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2675)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2465)
    at com.mysql.jdbc.StatementImpl.executeUpdateInternal(StatementImpl.java:1536)
    at com.mysql.jdbc.StatementImpl.executeLargeUpdate(StatementImpl.java:2585)
    at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1464)
    at Zaroflightsystem.FlightManagementSystem.addFlight(FlightManagementSystem.java:22)
    at Zaroflightsystem.Main.main(Main.java:25)         

您应该在字符串之间添加单引号。(2,'we','we',2,30.0)。并且您应该在中查找您的查询。如果我输入输入并想要获得iput,是否需要执行prepared语句?prepared语句有多种好处,如性能和防止SQL注入攻击。