File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class.forName("..");

 
Pankaj Patro
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can I connect to 2 different database server in a single JDBC application?

Or is it possible to call Class.forNmae("url1"); for a type 1 database server, then Class.forName("url2); for a type 2 databse server, in my JDBC application.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can connect to as many different databases as you need to. It doesn't matter of which type they are, and by which means you acquire them. Also, you can call the Class.forName() methods all before you make the connection.

By the way, a database server does not have a type, the JDBC driver for a database has a type.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using a JDBC 2.0 driver? If so, obtain an InitialContext to obtain a DataSource by a JNDI lookup, and use the DataSource to get your Connection. You will need a DataSource for each DB.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic