简体   繁体   English

com.microsoft.sqlserver.jdbc.SQLServerException: ')' 附近的语法不正确

[英]com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near ')'

Iam getting a error in String qquery when i run the code Incorrect syntax near ')'.当我Incorrect syntax near ')'.运行代码时,我在 String qquery 中遇到Incorrect syntax near ')'. my sql qquery is running well in sqlserver he minus the products quantity .Any idea ?我的 sql qquery 在 sqlserver 中运行良好,他减去产品数量。知道吗? ty

error log错误日志

at mylogin.Basket.makesales(Basket.java:160)
    at mylogin.Basket.ReceiptActionPerformed(Basket.java:455)
    at mylogin.Basket.access$100(Basket.java:23)

Here is my code这是我的代码

      public void  executeSQLQuery (String query,String message) {
        Connection con =getConnection();
        Statement st;
        try{
            st =con.createStatement();
            if((st.executeUpdate(query))==1)
            {
               con.commit(); 

               DefaultTableModel model=(DefaultTableModel)jTable_ProSales.getModel();
                model.setRowCount(0);
               show_Basket_in_Jtable();
                JOptionPane.showMessageDialog(null,"Data "+message+" Succefully");
            }else{
                JOptionPane.showMessageDialog(null,"Data Not "+message+ "Error");
            }

                }catch (Exception ex){
                    ex.printStackTrace();
                }
}

action button动作按钮

 private void ReceiptActionPerformed(java.awt.event.ActionEvent evt) {                                        
        String query= "INSERT INTO Sales (Pro_Id ,Pro_Name,Sales_Quantity,Pro_Price ) SELECT Pro_Id,Pro_Name,Sales_Quantity ,Pro_Price FROM Receipt";
    executeSQLQuery(query,"Inserted");
  String qquery= " UPDATE Products SET Pro_Quantity= Products.Pro_Quantity - Receipt.Sales_Quantity FROM Products INNER JOIN Receipt ON Products.Pro_Id = Receipt.Pro_Id)" ; 
       executeSQLQuery(qquery,"updated");
    } 
 private void ReceiptActionPerformed(java.awt.event.ActionEvent evt) {                                        
        String query= "INSERT INTO Sales (Pro_Id ,Pro_Name,Sales_Quantity,Pro_Price ) SELECT Pro_Id,Pro_Name,Sales_Quantity ,Pro_Price FROM Receipt";
    executeSQLQuery(query,"Inserted");
  String qquery= " UPDATE Products SET Pro_Quantity= Products.Pro_Quantity - Receipt.Sales_Quantity FROM Products INNER JOIN Receipt ON Products.Pro_Id = Receipt.Pro_Id" ; 
       executeSQLQuery(qquery,"updated");
    } 

暂无
暂无

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

相关问题 com.microsoft.sqlserver.jdbc.SQLServerexception:'='附近的语法不正确 - com.microsoft.sqlserver.jdbc.SQLServerexception:incorrect syntax near'=' com.microsoft.sqlserver.jdbc.SQLServerException:'GO'附近的语法不正确 - com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'GO' com.microsoft.sqlserver.jdbc.SQLServerException: '=' 附近的语法不正确 - com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '=' com.microsoft.sqlserver.jdbc.SQLServerException: '|' 附近的语法不正确 - com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '|' Microsoft SQL Server JPA存储过程com.microsoft.sqlserver.jdbc.SQLServerException:'{'附近的语法不正确 - Microsoft SQL Server JPA Stored Procedure com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '{' com.microsoft.sqlserver.jdbc.SQLServerException:'@ P0'附近的语法不正确 - com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '@P0' Vaadin错误:com.microsoft.sqlserver.jdbc.SQLServerException:'LIMIT'附近的语法不正确 - Vaadin error : com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'LIMIT' com.microsoft.sqlserver.jdbc.SQLServerException 与 jpa - com.microsoft.sqlserver.jdbc.SQLServerException with jpa Error-com.microsoft.sqlserver.jdbc.SQLServerException:关键字“ BY”附近的语法不正确 - Error-com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the keyword 'BY' com.microsoft.sqlserver.jdbc.SQLServerException:用户登录失败 - com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM