Display All Available JDBC/ODBC Data Sources

R

Rich

All,

I'm working on a piece of code to allow the user to select from a list
of JDBC/ODBC data sources. For example, assume I have four Access ODBC
data sources. How do I enumerate these?

After a lot of searching on Google, I found the following:

/////////////////////////////////////////////////////////////////////////
Enumeration enum = DriverManager.getDrivers();
System.out.println(" Before - while (enum.hasMoreElements())");
while (enum.hasMoreElements())
{
System.out.println("Has Driver");
System.out.println(enum.nextElement().toString());
}
System.out.println(" After - while (enum.hasMoreElements())");
/////////////////////////////////////////////////////////////////////////

However, it does not return anything. Does the JDBC/ODBC bridge need
to be configured? I am missing something here?

Thanks,

RB
 
A

A Baba

JDBC does not have a DSN like ODBC and there is no way you can enumerate
existing ODBC DSNs in Java. The only way to do that is to use JNI and
get ODBC datasource either by using ODBC API or quering Windows registry.

DriverManager.getDrivers() get you all the drivers that are currently
loaded in memory, not DSN names.

Regards,
AB


====================================================
You don't pay to get spam, why pay to clean it

Visit http://www.spammarshall.com for details
====================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top