• 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
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Connecting to DB Error

 
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone,

I am trying to connect to DB (Oracle 10g) through a Java code. Please take a look at the code:




But the problem is i am getting an error while connecting to the database:




Could you please tell me what's the problem here?
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


[Microsoft][ODBC Driver Manager]


Looks like you are trying to use the JDBC-ODBC bridge. I can't see that anywhere in the code you've posted (unless its in BBADataPurger?) so you are maybe not running the code you think you are.

That being said, the code you are trying to run seems to be trying to use a DataSource, not a Driver, which won't work. Also, are you intending to use the XA driver?
 
Bartender
Posts: 2662
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.

You are mixing up the oracle jdbc driver and the Sun jdbcodbc bridge.

This point out that you want to use Oracle jdbc driver:
oracle.jdbc.xa.client.OracleXADataSource

and this is a mix between jdbcodbc and Oracle jdbc url:
jdbc:odbc:[email protected]:1522:CAP

Regards, Jan

[Paul types faster]
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what changes do i have to make here? Should i change this:

or

I am trying to connect to a database which is on the server from my local system. Its a strandalone java class.
Complete class is:
 
Jan Cumps
Bartender
Posts: 2662
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can find both the neccessary driver class info and the url instructions at Oracle.
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is using an XA an advisale way to go about this?

I changed my code to:


and now i get the error:
 
Jan Cumps
Bartender
Posts: 2662
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Somnath Mallick wrote:....
and now i get the error:


Solution on same url as in my previous post.
Look for: Installation
How do I install the Thin driver?
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The solution given:

How do I install the Thin driver?
Put the jar files in a convenient location and include the appropriate jar files in your classpath. See What are all these files for? to determine which files you need.



I have ojdbc14.jar and classes12.jar added in my classpath already. Are there any more jars to be added. I checked the list given in your link. All are different version of the two jars i already have!
 
Jan Cumps
Bartender
Posts: 2662
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Only put the correct .jar in the classpath.

Class.forName("oracle.jdbc.xa.client.OracleXADataSource");

How sure are you about this part of your code?
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Those are very old versions of the driver - are you running a 1.4 JDK or below? If not you'll need the correct files (see Jan's link)

 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pretty much sure. Because i used this many times in other places where i was able to connect and work on DB's.
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Sturrock wrote:Those are very old versions of the driver - are you running a 1.4 JDK or below? If not you'll need the correct files (see Jan's link)


Could you please let me know what are the latest versions of the jar? I have to catch a flight in 2 hours. and i am already running late. I will download them when i get home!
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Somnath Mallick wrote:Pretty much sure. Because i used this many times in other places where i was able to connect and work on DB's.



Its odd to see someone load a DataSource this way. More normally you would register a Driver with the DriveManager not a DataSource. And using the XA tends to be the exception rather than the rule. Do you need an XA driver?
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Somnath Mallick wrote:
Could you please let me know what are the latest versions of the jar? I have to catch a flight in 2 hours. and i am already running late. I will download them when i get home!



I'm not sure I could answer this any better than Oracle do in Jan's link. Have a read of those FAQs.
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you please show me an example which shows a proper way of getting data from a DataSource. I have loaded XA drivers this way in quite a few codes and they all worked without any issues.
 
Jan Cumps
Bartender
Posts: 2662
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm getting a bit lost.
Do you still have issues with the original code from the first post?
Or is the original code now working, and do you want to go a step further?

Regards, Jan
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code is not working!

And would definitely like a step further!
 
Jan Cumps
Bartender
Posts: 2662
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What if you take a brand new start?

- get the correct version of the jar file for matches your database version, and stop using any other Oracle JDBC .jar
- register the correct driver. (see also the linc toOracle basic instructions below.
- use the correct url to connect to your Oracle database.
- test.

Oracle's First Steps in JDBC.

I have loaded XA drivers this way in quite a few codes and they all worked without any issues.

We don't believe that anymore

Regards, Jan
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic