The code is showing the error in .executeUpdate statement. I tried to execute the sql statement through Java. The error is showing in the line
rs = stmt.executeUpdate(upquery);
And the error is : Incompatible Types Found: int Required: java.sql.ResultSet;
Before starting the coding i imported certain things globally:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.ResultSet;
Action code:
try{
int srl = Integer.parseInt(srlTF.getText());
String date = dateTF.getText();
String part = paTF.getText();
float amt = Float.parseFloat(amtTF.getText());
float exp = Float.parseFloat(expTF.getText());
float pro = Float.parseFloat(proTF.getText());
Class.forName("com.mysql.jdbc.Driver");
String usr = "root";
String pwd = "root";
String DB_URL = "jdbc:mysql://localhost/accounts?user="+usr+"&password="+pwd;
con = DriverManager.getConnection(DB_URL);
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CLOSE_CURSORS_AT_COMMIT);
String upquery = "insert into hostmargin_acc values(" + srl +","+ "'"+ date +","+ part +","+ amt +","+ exp +","+ pro + ");" ;
rs = stmt.executeUpdate(upquery);
msgLB.setText("BrO! Pwolichu! Save Chietu Kallan");
}
catch (Exception ex){
System.out.println(ex.getMessage());
}
... "'"+ date +"," ....