I want to change the sid in the URL i.e(conn=DriverManager.getConnection("jdbcracle:thin:@localhost:1521:XE","scott","tiger");. My requirement is that the user must be asked for the SID and the SID should be set. I can do that if i have one or two URL's. The problem is that i have used it many times the URL in different classes. Now what can i do to achieve my requirement.
you mean that i should use the Connection class directly. The problem is in my real application i needed to establish connection many times so to get rid of that i created a new connection class. The advantage is that if the database changes also, it will be easy to change the SID and all the crap. So i thought it will be flexible o use a different connection class.
Hope you got me.
Not good. You create two connections. One in line 11 and 1 in line 21.
You use the one from line 11.
You get a new one in line 21, and close it immediately.
You don't close the one from line 11.
Joined: May 29, 2008
Thanks for your reply. There is a advantage if i use the above method, because where ever there is a change in connection parameters i have to change at one place only. Can you tell me how can i overcome the above drawback.
What you said is wright Rene. Now suppose 10 classes are there each class has code related to transaction with the database, then i have to use the Connection object 10 times. I should also give all the parameters i.e SID username and password. I don't want to do that. Instead do something where i have to give all those at only one place. Hope you got me.
Are you using the Connection(s) from a standalone Application or from a Web Server??
If it is from a standalone Application, then you need to code a Connection Pool class collection, where YOU control how connections are started and closed - and how they are re-newed or closed after a number of time used (or what you decide).
When your application start up ALL connections will be generated as you have decided they should be (how many initial, how many allowed idle - etc.)
If you are using a Web Server, you need to set up the connection to use on the server - then they will be handled by the web container.