简体   繁体   English

在JDBC中的SQL查询中获取语法错误

[英]Getting Syntax error in SQL query in JDBC

I am getting a syntax error, but I am mostly sure I am doing everything right. 我收到语法错误,但我大部分可以肯定我所做的一切正确。 Could you take a look? 你可以看看吗?

String ORDER, DROP, CAR;

            String Statement = "INSERT INTO WORKORDER"
                    + "(ORDER, DROPOFFDATE, COMPLETIONDATE) VALUES "
                    + "( ?, ?, null);";

            //JOptionPane.showMessageDialog(frame, Statement, "Daisy Imports", 3);
            try {
                PreparedStatement PST = connection.prepareStatement(Statement);
                ORDER = JOptionPane.showInputDialog("Please assign a order number for this order");
                int ORDERi = Integer.parseInt(ORDER);
                DROP = JOptionPane.showInputDialog("Please Enter the date the car was dropped off (YYYY-MM-DD)");
                CAR = JOptionPane.showInputDialog("Enter the VIN for the car this work order is for");
                PST.setInt(1, ORDERi);
                PST.setString(2, DROP);
                PST.execute();

Try getting rid of the semicolon at the end of your prepared statement. 在准备好的语句末尾尝试摆脱分号。

Edit: The problem was that "ORDER" is a reserved word. 编辑:问题是“ ORDER”是保留字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM