在GUI java中向表插入新记录

在GUI java中向表插入新记录,java,mysql,Java,Mysql,我正在将一个新数据插入mysql数据库。我有个错误说 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 '')' at line 1 有人能告诉我我的代码有什么

我正在将一个新数据插入mysql数据库。我有个错误说

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 '')' at
 line 1
有人能告诉我我的代码有什么问题吗?这是我的密码:

public class ButtonListener implements ActionListener{
    public void actionPerformed(ActionEvent e){
        String queryString = "";
        String queryString2 = "";
        String outputString = "";
        try {
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            connection = DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/dealer", "root", "admin");
            statement = connection.createStatement();
            String driverID = driverIdTextField.getText();
            String firstName = firstNameTextField.getText();
            String lastName = lastNameTextField.getText();
            String address = addressTextField.getText();
            String phone = phoneTextField.getText();
            String license = licenseTextField.getText();
            String brand = brandTextField.getText();
            String model = modelTextField.getText();
            String year = yearTextField.getText();
            String selectItem = (String) carStatus.getSelectedItem();

            queryString = "insert into person values ('" + (driverID) + "' + '" + (firstName) + "' +  '" + (lastName) + "' + '" + (address) 
                + "' + '" + (phone) + ")";
            queryString2 = "insert into cars values ('" + (license) + "' + '" + (brand) + "' + '" + (model) + "' + '" + (year)
                + "' + '" + (selectItem) + ")";

            statement.executeUpdate(queryString);
            statement.executeUpdate(queryString2);
            connection.close();
        } catch (SQLException sqlException){
                sqlException.printStackTrace();
        } catch ( ClassNotFoundException x ) {
            x.printStackTrace();
        } catch ( InstantiationException x ) {
            x.printStackTrace();
        } catch ( IllegalAccessException x ) {
            x.printStackTrace();
        }
    }
这是我的桌子。我有两张桌子

create table person
( driverID int unsigned not null primary key,
  firstName char(20) not null,
  lastName char(20) not null,
  address char(30) not null,
  phone int unsigned
);

create table cars
( license char(10) not null primary key,
  brand char(20) not null,
  model char(20) not null,
  year date,
  status char(10) not null
);

谢谢你的帮助

INSERT语句中缺少逗号(您使用的是加号)

(我认为您在这一行中还缺少了一个右引号)

我建议a)打印出您用作查询的字符串对象,这将使语法中的任何错误更具可读性b)使用PreparedStatement执行查询。
queryString = "insert into person values ('" + (driverID) + "', '" + (firstName) + "',  '" + (lastName) + "', '" + (address) 
            + "', '" + (phone) + "')";