Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / August 2004

Tip: Looking for answers? Try searching our database.

datasource without JNDI?

Thread view: 
kaeli - 25 Aug 2004 19:23 GMT
Is there a way to use a datasource to connect to a DB besides using JNDI?
Right now, my connection string is hard-coded and it's a minor pain to change
between the production and test databases. I'd prefer to have it in a config
file somehow, but JNDI seems like way more than I need for a small
application.
Any hints?

Tips on setting up that datasource in Netscape Enterprise Server (IPlanet)
also welcome, though a bit OT.

Thanks!

Signature

--
~kaeli~
When two egotists meet, it's an I for an I.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Lee Fesperman - 26 Aug 2004 03:42 GMT
> Is there a way to use a datasource to connect to a DB besides using JNDI?
> Right now, my connection string is hard-coded and it's a minor pain to change
> between the production and test databases. I'd prefer to have it in a config
> file somehow, but JNDI seems like way more than I need for a small
> application.
> Any hints?

Just instantiate the datasource (it must have a no-args ctor), set the connection
properties and call getConnection(). For example:

 javax.sql.DataSource ds = new com.vendor.DataSource();
 ds.setServerName("godzilla");
 ds.setPortNumber(9999);
 java.sql.Connection connection = ds.getConnection("kaeli", "tiger");

You'll need to check the vendor docs or use reflection/inspection to find out the
connection properties.

Signature

Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com)
==============================================================
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS  (http://www.firstsql.com)



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.