File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "JDBC" Watch "JDBC" New topic


zena sam
Ranch Hand

Joined: Apr 26, 2002
Posts: 41
I have a few questions regd JDBC/SQL?
can we connect to multiple databases from one application using JDBC?
how can we verify the results expected from a query with the results produced....if the expected results are stored in a excel sheet?
Thanks in Advance!!
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
ONE: Yes, you can connect to multiple databases, and they can be of different types. So may have a connection to Sybase, two to Oracle, and one to MySQL. Just make sure you register all of the relevant drivers and then call DriverManager.getConnection(...) to create a connection to each database as needed. You just have to keep track of which connection is tied to which database so you process queries against the right database ...
TWO: How can you verify the results? Well, I guess you can save the results in any form you deem appropriate and compare it against what you expect. But if you submit the correct query, you'll get the correct results. JDBC has been in use for several years now and seems to work well ...
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

There's also at least one Excel JDBC driver. Or ability to read Excel using the JDBC-ODBC bridge, I forget which.
So you could do the "open more than one database" trick and one of the "databases" would be the Excel spreadsheet.
Just don't ask me how. I know it's possible, but for practical details, I'd have to RTFM

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: JDBC
It's not a secret anymore!