3 messages in com.mysql.lists.javaRe: Best Place to Load Driver | From | Sent On | Attachments |
|---|---|---|
| Willie Klein | 13 Nov 2002 08:53 | |
| Willie Klein | 15 Nov 2002 12:43 | |
| Steven Caswell | 18 Nov 2002 04:08 |
| Subject: | Re: Best Place to Load Driver ![]() |
|---|---|
| From: | Willie Klein (wil...@pdfsystems.com) |
| Date: | 11/15/2002 12:43:20 PM |
| List: | com.mysql.lists.java |
Thanks So much for your response Glenn.
I'm afraid I have more questions now though.
First Connection Pooling. I was under the impression that the were necessary for servlets running on a WebServer where multiple users are running from the same machine hitting a MySql Server. Since I'm writing a Standalone GUI are they still necessary? The MySql Server still is a separate machine but I'm thinking there will only be one connection to it from any given PC.
Or do I still need a connection pool because the user will need to connect multiple times to the database over the course of the day using the GUI. Maybe there is a simple way of doing it. Is there some Connection pool code anyone can recommend? I see some are not happy with poolman.
If there is some documentation you can point me too I would be especially grateful.
Thanks much
willie
Hi willei,
I've been loading the driver when the program starts in the static void main section.
Try to substract this from the base system. Make objects that do this for you and make sure that every object is responsible for it self. So, what you can do I think is just build 2 classes (for simple programs, ofcourse you can implement a better solution), a ConnectionPool and just MyConnection class, which implements the Connection interface, the ConnectionPool should be responsible for giving away database connections and hold open connections.
However no real action takes place until the user enters data and clicks on a button
So, do not actually load the driver but initialize the ConnectionPool class which is aware of the driver. The connectionPool initialize a given number of connection (I do most of the time 10 connections). When data needs to be retrieved it just looks for available connection, if any, and uses free connection to do your job! But that is not all do not initialize the connections on startup, but initialize this when the user ask for it the firt time. It will slow down retrieval the first time but after that it wiil go faster.
Would it be a problem to load the driver over and over as the user enters data?
This will actually be a very bad idea. At least make an object that thus this once and reuse it ove and over again (OOP).
Good Luck!
-----Original Message----- From: Willie Klein [mailto:wil...@pdfsystems.com] Sent: Wednesday, November 13, 2002 5:54 PM To: ja...@lists.mysql.com Subject: Best Place to Load Driver
Hi All;
I'm writing a GUI app with MySQL. I've been loading the driver when the program starts in the static void main section. However no real action takes place until the user enters data and clicks on a button. So that's where my connection statement is. Should I load the driver there also? Would it be a problem to load the driver over and over as the user enters data? Or should I leave the driver where it is though I'm having a problem writing exceptions to labels there.
Thanks;
willie
--------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/doc/ (the manual) http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <java...@lists.mysql.com> To unsubscribe, e-mail <java-unsubscribe-g.tramm=chel...@lists.mysql.com>




