If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > SQL1031N The database directory cannot be found......

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-27-07, 09:26
Dan Maher Dan Maher is offline
Registered User
 
Join Date: Dec 2007
Posts: 24
SQL1031N The database directory cannot be found......

I did a search and found a few other who have come across this problem and also resolved it. However they had access to the database itself and I don't.
I have a DB2 machine that was set up by the DB2 team at my work and it's working fine for them for a long time. Now I have a new computer on the network and I'm trying to write a Java application that will connect to the database and pull a few records from the tables. I have set up NOTHING but I was under the impression I didn't have to. As long as I give the correct parameters, I thought it would just connect. Is this right?
So far I have copied the JDBC drivers to the /Program Files/Java/jre1.6.0_03/lib/ext/ folder and written a simple application which will use them to connect to the database but I get this error:
Quote:
com.ibm.db2.jcc.c.SqlException: SQL1031N The database directory cannot be found on the indicated file system. SQLSTATE=58031
And here is the code I wrote, it's very simple:
Quote:
import java.sql.*;

/**
* @author Daniel Maher
*
*/
public class db2Test
{

/**
* @param args
*/
public static void main(String[] args)
{
// Load JDBC driver.
try
{
Class.forName("COM.ibm.db2os390.sqlj.jdbc.DB2SQLJD river");

String databaseUsername = "*******";
String databasePassword = "********";
String databaseURL = "jdbc:db2:devbdw";

Connection conn = DriverManager.getConnection(databaseURL, databaseUsername, databasePassword);
conn.close() ;
}

catch (Exception e)
{
System.err.println("Got an exception: " + e);
}
}
}
From my research on the error, it's telling me my URL is incorrect and it can't find the database I'm looking for. But I got the username/password/URL from the DB2 team and they say they're using them currently. Any ideas at all? I'm stumped.
Reply With Quote
  #2 (permalink)  
Old 12-27-07, 11:17
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
If you use the type 2 connection (which is what appears that you are using), you must have the DB2 client installed and must catalog the remote database (in the client database directory).

If you use the type 4 (universal) connection, you do not need the db2 client installed but you do need the DB2 jars on the client. No cataloging of remote databases is necessary on the client because the type 4 connection string contains the server, port, database-name, user, and password.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 12-27-07, 11:27
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Hmmm. I just noticed the following:

Class.forName("COM.ibm.db2os390.sqlj.jdbc.DB2SQLJD river");

If you are trying to connect to an OS/390 DB2 database, you will need DB2 Connect (or at least a DB2 connect license). DB2 Connect can be on the client, or it can be installed on a gateway machine (UNIX, LINUX, Windows) that allows multiple clients to use the same DB2 Connect.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #4 (permalink)  
Old 12-27-07, 12:10
Dan Maher Dan Maher is offline
Registered User
 
Join Date: Dec 2007
Posts: 24
Interesting, so just go to ibm.com and download DB2 Connect, install it and run it? Then that should fix the error?
Reply With Quote
  #5 (permalink)  
Old 01-02-08, 10:16
Dan Maher Dan Maher is offline
Registered User
 
Join Date: Dec 2007
Posts: 24
I'll need this to connect with something like Rapid SQL as well, correct?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On