I am building a Swing app that references and updates mySQL on
localhost.
It seems to me that I would create the connect.java class in a
separate file, outside of main, and have an instance of that class
created in main.java. In turn all windows (all of which are in
separate classes) would reference the connection object that lives
within main.java.
It seems this is the way it should be done, but I'd like to see how
the pros suggest. Not sure how clearly this concept needs to be
illustrated, but here goes...
// connect.java
import java.sql.*;
public class connect {
public static Connection conn = null;
public connect($driver, $ip, String $db, $user, $pass) {
// start appropriate try & exception catches...
Class.forName($driver).newInstance();
public class Main {
Connection conn;
public class attemptConnect($driver, $ip, $db, $user, $pass) {
Connection conn = new connect($driver, $ip, $db, $user, $pass);
}
public static void main(String[] args) {
// initialize and display windows within protected theads.
}
}
public class myWindow1 {
//when a button is pushed...
main.attemptConnect($uiDriver, $uiIP, $uiUser, $uiPass);
// myWindow1 is hidden
//myOtherWindow is made visable....
}
public class myOtherWindow {
main.conn.createStatement().exectueQuery("SELECT * FROM users");
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden