gpt4 book ai didi

java - com.microsoft.sqlserver.jdbc.SQLServerException : There are more columns in the INSERT statement than values specified in the VALUES clause

转载 作者:行者123 更新时间:2023-11-28 23:25:57 24 4
gpt4 key购买 nike

<分区>

我有一个问题,我不知道如何解决。我遇到了这个错误,但我不确定这个错误是否会出现,因为我正在尝试使用 extends 调用 2 个函数

com.microsoft.sqlserver.jdbc.SQLServerException: There are more columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:196)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1454)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:786)
at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:685)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4026)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1416)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:185)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:160)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeUpdate(SQLServerStatement.java:642)



at mylogin.Orders.executeSQLQuery(Orders.java:147)
at mylogin.Orders.Make_OrderActionPerformed(Orders.java:439)
at mylogin.Orders.access$100(Orders.java:23)

这是我的代码似乎有问题(在 mylogin.Orders.executeSQLQuery(Orders.java:147))

  //execute the sql query REFRESH JTABLE 
public void executeSQLQuery (String query,String message) {
Connection con =getConnection();
Statement stt;
Statement sttt;
try{
stt =con.createStatement();
sttt =con.createStatement();
// **1 error 147**
if(((stt.executeUpdate(query))==1) || ((sttt.executeUpdate(query)) )==1)

{
//refresh jtable data
DefaultTableModel model=(DefaultTableModel)jTable_Orders.getModel();

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

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

这是我的代码似乎有问题(在 mylogin.Orders.Make_OrderActionPerformed)

  private void Make_OrderActionPerformed(java.awt.event.ActionEvent evt) {                                           
String query="INSERT INTO Orders(Pro_Id ,Pro_Name,Order_Quantity,Order_Date,Order_Id)VALUES ('"+Pro_Id.getText()+" ','"+Pro_Name.getText()+" ','"+Order_Quantity.getText()+" ,'"+Order_Date.getText()+" ,'"+Order_Id.getText()+" ') ";
executeSQLQuery(query,"Inserted");
}

最后是这一点(在 mylogin.Orders.access$100)

public class Orders extends  javax.swing.JFrame {

/**
* Creates new form Orders
*/
public Orders() {
initComponents();
show_Products_in_Jtable();
show_Orders_in_Jtable();
}

我被困在这个点上好几天了有什么帮助吗???泰!

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com