JavaFX仅在某些数据上获取MySQLSyntaxErrorException

时间:2016-12-08 19:51:02

标签: mysql javafx syntax-error javafx-8 mysql-error-1064

我正在尝试将一些数据更改为mysql,对于某些项目或id(PK),它工作正常,但对于其中的2或3个,我得到MySQLSyntaxErrorException。

以下是代码:

@FXML
    public void azhurnoPaisjen() throws ClassNotFoundException, SQLException
    {

        Class.forName("com.mysql.jdbc.Driver");
        String url = "jdbc:mysql://localhost:3306/*****";
        String user = "******";
        String pass = "******";
        connect = DriverManager.getConnection(url, user, pass);
        PreparedStatement ptmt;
        double pagesa = Double.parseDouble(qmimi.getText()) + Double.parseDouble(puneDore.getText());
        System.out.println(pagesa);
        String query = "update paisjettable set prodhuesi='"+ prodhuesi.getText() +"' , modeli='"+ modeli.getText() +"' , paisja='"+ paisja.getText() +"' , pjesa='"+ pjesa.getText() +"' , qmimi='"+ Double.parseDouble(qmimi.getText()) +"' , punedore='"+ Double.parseDouble(puneDore.getText()) +"' , pagesa='"+ pagesa +"' , sasia='"+ Integer.parseInt(sasia.getText()) +"' , infoshtese='"+ info.getText() +"'  where id='"+ id +"'";
        ptmt = connect.prepareStatement(query);
        ptmt.executeUpdate();  // THIS IS LINE 98

        ptmt.close();
        connect.close();
        PaisjetController.azhurnoPaisjen.close();
    }

输出:

Caused by: com.mysql.jdbc.exceptions.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 'Alumin'  where id='18'' at line 1
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1604)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1519)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1504)
    at automekanikadmin.AzhurnoPaisjenController.azhurnoPaisjen(AzhurnoPaisjenController.java:98)
    ... 110 more

p.s" 17' Alumin"是来自info(TextArea)的文本

0 个答案:

没有答案