Tim Holloway wrote:It sounds like what you probably need is a singleton object that you can obtain the Connection from (have it create the Connection the first time it is called).
For multi-user applications (Swing apps usually aren't), there are some Database Connection Pool libraries such as Apache dbcp that can be used to manage shared pools with multiple connections in them. Apps like Apache Tomcat use* this instead of inventing their own).
===
* Actually, up to about Tomcat 7, they used Apache dbcp, I think later versions switched to a different provider. Tomcat's connection pooler was always plug-replaceable though.
I don't want multi-user configuration. These is my organizacion:
JFRAME (main) -> multiple buttons that open JDIALOGs to make querys in database and one of them open Jdialog to configure database (for instance JDialogDatabase)
JDIALOG JDialogDatabase with JTextField with name database, user, port, pass...., and Jbutton to text connectivity of that configuration
CLASS CONNECTION -> Is called from JDIALOG JDialogDatabase to connect to database and return to JDIALOG the output of the connection to see the connection is established.
How could you organize better that?
Thanks!