I am new to the forum, and while I have some general programming experience and education, I'm pretty green when it comes to Java technologies. Currently, I'm looking for some help understanding how to use DataSources.

Here is some background on what I want to accomplish. I am writing a Desktop application that does financial modeling. The model will read in individual records from a database table and process each one. I would like to avoid hard coding my application for any specific database(s).

I have some experience working on a similar application written in C that utilized ODBC. That setup worked great. An administrator would set up ODBC data sources (there was an ODBC Administrator application to assist with this, the data sources were stored in a file, odbc.ini) and my application would query the ODBC system for the available data sources. The application user would be presented with a list of data sources, select one, then be presented with a list of available tables, select one, and be on with the show. To make a new data source available to the application, the system administrator just needed to configure it, and like magic, it would be available to the application user.

So, now that I am looking to develop a new application with Java, I turned to JDBC hoping to get similar functionality. I have read through the JDBC trail, but perhaps I missed something. I found the examples to generally use the DriverManager, although the trail later mentioned that using a DataSource was preferred to the DriverManager. The trail then went on to say that DataSources could be stored and accessed with JNDI. So, I guess my questions are as follows:

1.) There is no desktop standard for configuring data sources, analogous to the odbc.ini file that ODBC used? I infer this from the reference to using JNDI.

2.) Is storing Data Sources in a naming service the best solution? I feel like I am placing extra requirements on my application users and their system administrators. In order to get the functionality I desire, the administrators are going to need to set up a naming service, and then get Data Sources in there. The application users are going to need to point the application to the naming service, and then specify where in the naming service to find the Data Source objects, which is all I really wanted in the first place.

3.) How do the Data Source objects get setup / configured / instantiated?

Thank you for your comments in advance,

Jason

March 4th, 2010, 09:37 PM

jasonm

Re: Setting up, using DataSources

Maybe I should take a step back. Have you worked on applications that implement data access through DataSources rather than directly using the DriverManager?

How does the application retrieve the DataSources? What configuration is required of the application users? What set up is required of their system administrators?