Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Application and Database on the same server

843853Aug 31 2001 — edited Jan 29 2003
I have a Java Application and a db2 database(SWDTEST) that reside on the same server. In the Application I want to connect to the database. What would I use to do this? When the application resides on a client machine I use the "sun.jdbc.odbc.JdbcOdbcDriver" driver and can get a connection. Code looks like:

try{
//load the driver class
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

//Define the data source for the driver
String wdURL = "jdbc:odbc:SWDTEST";
String username = "UNTEST";
String password = "PTEST";

wdConnection = DriverManager.getConnection(wdURL, username, password);

wdStatement = wdConnection.createStatement();
}
catch(SQLException e)
{
System.out.println( e.toString() );
}


But when I move the same application to the server and run it I get the following error message:

java.sql.SQLException: [IBM][CLI Driver] SQL1013N The database alias name or database name "SWDTEST" could not be found. SQLSTATE=42705

Do I need to set something on the server so that SWDTEST is a recognized database name or connect to it some other way?

Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 26 2003
Added on Aug 31 2001
3 comments
202 views