Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2007
    Posts
    24

    Unanswered: 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:
    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:
    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.

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

  3. #3
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

  4. #4
    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?

  5. #5
    Join Date
    Dec 2007
    Posts
    24
    I'll need this to connect with something like Rapid SQL as well, correct?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •