Reputation: 13
The SQL code runs perfectly fine in mysql, and my other statements in this application work but this one saying my table dosn't exist when it clearly does, Made sure all the syntax is right so i don't understand why its not working, My code is posted below
private void salesReportbtnActionPerformed(java.awt.event.ActionEvent evt) {
try {
con = DriverManager.getConnection(url, user, password);
stmt = con.createStatement();
result = stmt.executeQuery("SELECT Prod_Srv_ID , `The_Organizations_Organization_Name` ,"
+ " `Prod_Srv_Details` , `Prod_Srv_Price` , `Prod_Srv_Discount` `Contracts_Contract_Number` ,"
+ " `Shipment_Completed`\n"
+ "FROM product_and_services\n"
+ "JOIN product_contract_line ON product_and_services.Prod_Srv_ID ="
+ " product_contract_line.Product_and_Services_Prod_Srv_ID");
int tempName = 4;
salesReportlist.setText("");
String Shipres;
while (result.next()) {
tempName = tempName + 1;
int prodID = result.getInt("Prod_Srv_ID");
String orgName = result.getString("The_Organizations_Organization_Name");
String Details = result.getString("Prod_Srv_Details");
double Price = result.getDouble("Prod_Srv_Price");
double Discount = result.getDouble("Prod_Srv_Discount");
double contractNum = result.getDouble("Contracts_Contract_Number");
int Ship = result.getInt("Shipment_Completed");
if(Ship == 1)
{
Shipres = "True";
}
else{
Shipres = "False";
}
if (tempName >= 5) {
salesReportlist.setText(salesReportlist.getText() + "\n" + " Product ID: " + prodID + " Organization Name: " + orgName + " Details: " + Details + " Price: " + Price+ " Discount: " + Discount + " Contract Number: " + contractNum + " Shipment Completed: " + Shipres );
} else {
JOptionPane.showMessageDialog(null, "Error");
}
}
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
}
}
Upvotes: 1
Views: 53
Reputation: 1481
Looks like space or comma issue in your query.The best way to solve it is print the query and try executing the printed query in your sql client.
looks like comma missing between Prod_Srv_Discount
Contracts_Contract_Number
hope this should solve the issue.
Upvotes: 1