facebook

Error while trying to login to database:

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #260550 Reply

    mominaqeel
    Member

    Hi,
    I have DB2 runtime client installed and configured properly on my desktop. I am trying to configure DB2 with myeclipse. IT gets configured but I’m unable to login, it gives me following message

    Error while trying to login to database:
    java.lang.reflect.InvocationTargetException : Error opening socket to server localhost/127.0.0.1 on port 50000 with message : null
    DB2ConnectorCorrelator: null

    And following are my configuration details

    Driver:IBM DB2 App Driver
    Connection URL:jdbc:db2://localhost:50000/PIMSQ
    Driver JAR Files: db2jcc.jar ;db2jcc_javax.jar ; db2jcc_license_cu.jar
    Driver classname: com.ibm.db2.jcc.DB2Driver

    Any help/direction would be really appreciated.

    Regards
    Aqeel..

    #260562 Reply

    Haris Peco
    Member

    Aqeel,

    It looks like jdbc driver/database issue or incompatibilty

    Please, send your OS version, DB2 database version and jdbc version
    Check with this simple application (it will print all tables in database or throw error)

    import java.sql.Connection;
    import java.sql.DatabaseMetaData;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    
    
    public class TestTables {
        private static String driverName = "YOUR_CLASSNAME";
    
        private static String url = "YOUR URL";
    
        private static String username = "YOUR_USERNAME";
    
        private static String password = "YOUR_PASSWORD";
    
        public static void main(String[] args) {
    
            try {
                Class.forName(driverName);
                Connection connection = DriverManager.getConnection(url, username,
                        password);
                DatabaseMetaData md = connection.getMetaData();
                // you can change first argument with your catalog (if database support catalog)
                // and second with schema
                ResultSet tables = md.getTables(null, null, "%", new String[] { "TABLE","VIEW" });
                while (tables.next()) {
                    String table = tables.getString("TABLE_NAME");
                    System.out.println("table=" + table);
                }        
            } catch (Exception e) {
                e.printStackTrace();
            }
    
        }
    }
    

    Regards,
    Peco

    #260589 Reply

    mominaqeel
    Member

    Hi Reco,
    Thanks for your reply.
    The Test Class gives same error as

    
    com.ibm.db2.jcc.a.DisconnectException: java.net.ConnectException : Error opening
     socket to server localhost/127.0.0.1 on port 50000 with message : Connection re
    fused: connect  DB2ConnectionCorrelator: null
            at com.ibm.db2.jcc.c.fc.a(fc.java:347)
            at com.ibm.db2.jcc.c.fc.<init>(fc.java:66)
            at com.ibm.db2.jcc.c.a.v(a.java:256)
            at com.ibm.db2.jcc.c.b.a(b.java:1631)
            at com.ibm.db2.jcc.a.p.<init>(p.java:856)
            at com.ibm.db2.jcc.c.b.<init>(b.java:308)
            at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:165)
            at java.sql.DriverManager.getConnection(DriverManager.java:512)
            at java.sql.DriverManager.getConnection(DriverManager.java:171)
            at com.test.TestTables.main(TestTables.java:21)
    

    Following are the details
    OS- Microsoft XP SP2
    DB2 versin 8.2

    Thanks
    Aqeel..

    #260591 Reply

    mominaqeel
    Member

    Hi,
    I found one thing, I can connect to Database explorer changing connection URL to
    jdbc:db2:<Database-name>
    but I’m still getting error while trying to get to that connections as below

    15:26:40,796 INFO [STDOUT] java.lang.ClassNotFoundException: No ClassLoaders found for: com.ibm.db2.jcc.DB2Driver
    15:26:40,796 INFO [STDOUT] at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:198)
    15:26:40,806 INFO [STDOUT] at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:464)
    15:26:40,806 INFO [STDOUT] at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:374)
    15:26:40,806 INFO [STDOUT] at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
    15:26:40,816 INFO [STDOUT] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
    15:26:40,816 INFO [STDOUT] at java.lang.Class.forName0(Native Method)
    15:26:40,816 INFO [STDOUT] at java.lang.Class.forName(Class.java:141)

    Can any one plz help me with these error.

    Regards
    Aqeel..

    #260597 Reply

    Haris Peco
    Member

    Aqeel,

    Your error means that your driver class is not in claspath.If you use the application from previous post) then you have to add jdbc jars to project’s classpath and if you use MyEclipse’s connection profile then you should add jars in driver’s classpath

    I advice you that you try with jdbc class 4 driver (your first URL), because it works much better.MyEclipse will work with type 2 driver, but you will got issues with redefining driver (this is because exists constraint in JVM)

    For type 4 driver you have to set correct hostname, port and database like this

    jdbc:db2://localhost:50000/PIMSQ

    host name is ‘localhost’, port is 50000 and database is PIMSQ – This can be different for your database – double check if this information are correctand if you add correct jars from db2 8.2 distribution

    Best,
    Peco

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Error while trying to login to database:

You must be logged in to post in the forum log in