Application and Database on the same server
843853Aug 31 2001 — edited Jan 29 2003I 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.