I'm having a bit of trouble with this bit of syntax:
Connection con = null;
Statement st = null;
ResultSet rset = null;
/**
* Creates new form formUsers
*/
public formUsers() {
initComponents();
con = SQLInteract.SQLInteract();
tableUpdate();
}
I am attempting to call the connection to a MySQL database I have already made, which is contained in the constructor method for the class. Am I merely screwing up the syntax in some way, or can I not do that at all? Or is it really as simple as just using:
SQLInteract Connect = new SQLInteract();
As requested; here is the SQLInteract syntax:
Connection con = null;
Statement st = null;
ResultSet rset = null;
public SQLInteract() {
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/chemsimdb","root","");
}catch(Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
SQLInteractclass.SQLInteract? becauseSQLInteract Connect = new SQLInteract();will not give a connection object it gives a instance of SQLInteract class, if you want to access the connection object created inside you need a getter method