• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Query in JDBC connection

 
lakshman kumaran
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have doubt in JDBC connection. Actually i have two driver in the same application 1.oracle driver 2.sql driver

First i load the oracle driver using class.forName method and then loads the sql driver. i don't know which driver currently i am going to use . is it possible to connect both drivers . could you tell me anybody

Thanks in advance
Lakshman




 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can have as many connections, to as many drivers as you like.
just create a new connection()
 
Matthew Brown
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The driver that gets used for each connection depends on the connection string. For instance, the Oracle driver might recognise connection strings starting with jdbc:oracle:thin:, so if you provide a string like that it will use that driver.
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just found this useful page, maybe it might be helpful
connection FAQ
 
lakshman kumaran
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At a time both driver i loaded. Please see the following code

class.forName("oracleDriver");

then next line to be

class.forName("SQLDriver");

could you please tell me currently which driver have loaded in class loader?


Thanks in advance
Lakshman

 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If these are the actual driver names you used in your code "OracleDriver" and "SQLDriver" then neither as they are invalid. but if you got the correct driver names then both.

You have hundreds of classes loaded all the time.


 
Rob Spoor
Sheriff
Pie
Posts: 20751
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lakshman kumaran wrote:could you please tell me currently which driver have loaded in class loader?

Both. As Matthew said, the connection String determines which driver is used. A connection String that starts with jdbc.oracle.thin:// will cause the Oracle driver to be used. A connection String that starts with jdbc:microsoft:sqlserver:// will cause the older SQL Server driver to be used. A connection String that starts with jdbc:sqlserver:// will cause the newer SQL Server driver to be used. A connection String that starts with jdbc:mysql:// will cause the MySQL driver to be used. Etc, etc, etc.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic