• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Query in JDBC connection

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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




 
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can have as many connections, to as many drivers as you like.
just create a new connection()
 
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 L Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 L Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
Sheriff
Posts: 22815
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Too many men are afraid of being fools - Henry Ford. Foolish tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic