Wait a minute, I'm trying to think of something clever to say...<p>Joel
Originally posted by Joel Cochran:
This is my first stab at JDBC. I've written a simple class that accesses our database and prints out a list of records from a file. In order to make it work, though, I had to hard code the IP address, the user name, and the user password.
I've heard of something called a Property file that I could store the IP address in and retrieve it so that I could softcode the IP address, so my first question is where do I learn about property files, how do I access them, etc.
what you can use is a ResourceBundle (java.util.ResourceBundle) it is rather simple to use:
ResourceBundle rb = ResourceBundle.getBundle(myFile);
String ip = rb.getString(myIpAdresse);
......
your file must be in the classpath
My second question is about the user... I don't want the user to store id and password information on individual PCs. What I need help with is understanding the architecture involved in building a standalone Java app for JDBC.
Here's what I had in mind. When a user opens the application, I'll have a log in screen which will create a User object. The user object then will get passed around throughout the application to provide this information. What I'm not sure about is the design itself: this would seem to mean a lot of Connections... is there a way to only create the connection once and then not close it until the user exits the application?
i do not know if it works in your case but you can keep your connection in the User Object you create ??
but be carrefull to close your connection at the End prehaps in the finalize method.
I never use this kind of management because i have only one database user and i access my data by a connection pool...
sorry if it doesn't help you
Sorry if this is a little muddy but that's the way I feel about this project right now...at least I have 14 months to get it done!
Thanks as always
Wait a minute, I'm trying to think of something clever to say...<p>Joel
Laurent LEONARD
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |