views:

465

answers:

2

Hi,

I need to develop an application that connects to various DSN's using the Microsoft ODBC drivers. I have developed the application in Eclipse and it seems to work properly. The connection succeeds and I am able to view table data.

However when I export the project to a runnable jar file (using Eclipse) the functionality fails for Oracle. It is unable to establish connectivity with the Oracle connection string. It still works for SQL server but fails in case of Oracle. I'm unable to figure out the cause as the same ODBC drivers are being used for both Oracle and SQL-Server. More mystifying is that it runs properly on Eclipse. Since im using the ODBC drivers I don't believe the problem is because of an external jar file.

The driver is sun.jdbc.odbc.JdbcOdbcDriver and connection string is like jdbc:odbc:oratest;user=fell;password=pass.

I'm getting the following exception

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)

Can you please help me figure what the problem might be?

Thanks in advance, Fell

+1  A: 

Create a System DSN.

java.sql.Connection cn;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=java.sql.DriverManager.getConnection("jdbc:odbc:dsn_name","user","pass");
adatapost
cool..thanks a lot...works just fine now !
Fell
A: 

Check the classpath in the eclipse project

QMP