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 Java Connectivity in Oracle 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 "Java Connectivity in Oracle" Watch "Java Connectivity in Oracle" New topic

Java Connectivity in Oracle

Suvojyoty Saha

Joined: Apr 19, 2011
Posts: 25

Hi I am trying to test the connection for oracle XE (10g) in Eclipse but i am getting the following Exception

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

I am using the following 10g resease 2 jar ojdbc14.jar and my code is Listed below

I created a USER DSN for Oracle XE and there the connection tests fine. The following driver if replaced with MYSQL Driver also tests fine but not able to get a clue as to what i am doing wrong here.
Wendy Gibbons

Joined: Oct 21, 2008
Posts: 1107

I am going to ask the obvious question, to get it over with,
You can connect using sqlplus with theese details?
Swastik Dey

Joined: Jan 08, 2009
Posts: 1584

Your connection string and and driver type are contradictory. You are trying to make odbc based connection, on the other hand your driver type is oci driver. Moreover your dsn name is missing in the code. Why not use thin driver?

Suvojyoty Saha

Joined: Apr 19, 2011
Posts: 25

Sorry Wendy I was not sure as to what I was doing. Was not aware that :thin@ needed to be mentioned. Was trying to use the OCIConnection class instead of trying to the driver class from the jar ojdbc14.

Thanks Swastik.

On changing these 2 lines of code i was able to connect.

I agree. Here's the link:
subject: Java Connectivity in Oracle
jQuery in Action, 3rd edition