G'day guys,
My boss has just asked me to develop a small CRM system. Now, writing a simple SQL Insert is not something im a stranger to, however for some reason i cannot seem to get this working.
I've included all necessary libraries, and tested the actual sql statement in my sql cli, but when running through java, it seems to hit a snag.
If anyone could have a look at my code below, and let me know what i've been doing wrong. Thanks.
I've just found the following error messages;
- java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
- INFO: Illegal access: this web application instance has been stopped already. Could not load java.net.BindException. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
import java.sql.*;
public class client {
.......
.......
public String addClient(){
boolean isCreated = false;
String sql = "";
try{
Connection con = new database().getConnection();
Statement stmt = con.createStatement();
sql = "INSERT INTO clients ("
+ " `clientID` , `companyName` , `clientFirstName` , `clientLastName` , `contactNumber` , `orderID`"
+ ")"
+ " VALUES ("
+ "NULL, '" + this.clientBusinessName + "', '" + this.clientFirstName + "', '" + this.clientLastName + "', '" + this.clientPhoneNumber + "', '1')";
stmt.executeQuery(sql);
isCreated = true;
}catch(SQLException e){ e.printStackTrace(); }
return isCreated ;
}
}