facebook

DB2 DBExplorer — java.lang.UnsatisfiedLinkError

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

    modha
    Member

    Hi
    I am trying to setup Database explore for my DB2 instance.

    When I try to add driver in Preferences -> MyEclipse->Datbase Explorer ->Drivers New

    I am getting the following error..
    java.lang.UnsatisfiedLinkError: Native Library C:\SQLLIB\bin\db2jdbc.dll already loaded in another class loader.

    Driver Template: IBM DB2 (Universal Driver)
    Driver Name: IBM DB2 (Universal Driver)

    My Java Program which I ran from command line works fine..

    
    import java.sql.Statement;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.*;
    
    public class test {
        public static void main(String[] args) {
            System.out.println("Connection/SQL test starting in TestSQL.java...");
    
            String driver = "COM.ibm.db2.jdbc.app.DB2Driver";
            String url = "jdbc:db2:test";
            String userid = "user";
            String password = "password";
    
            Connection connection = null;
    
            try { // load the driver
                Class.forName(driver);
            } catch (Exception e) {
                System.out.println("error loading driver");
                e.printStackTrace();
                return;
            }
    
            try {
                connection = DriverManager.getConnection(url, userid, password);
                System.out.println("Connection successful!");
    
                DatabaseMetaData databaseMetaData  = connection.getMetaData();
    
                String databaseProductName =
                databaseMetaData.getDatabaseProductName();
                String databaseProductVersion =
                    databaseMetaData.getDatabaseProductVersion();
    
                System.out.println("Database Product Name: " + databaseProductName);
                System.out.println("Database Product Version: " + databaseProductVersion);
    
    
    
            } catch (SQLException e) {
                System.out.println("Caught SQLException: " + e.getMessage());
                e.printStackTrace();
            } finally {
                try {
                    connection.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    

    Please let me know where the problem can be.

    Thanks
    Modha/-

    #256766 Reply

    modha
    Member

    I have added the db2jdbc.dll under C:\Program Files\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.eclipse.desktop_5.0.0\lib
    well actually if I create a new driver and exit it is fine.
    Now if I go back and change (just click on edit button) do not do anything and save it gives the error.

    So I created the driver, added a connection. Right click open the connection it opens. However if I click on the + sign next to connected to test, I see nothing under it.

    I wish there is a proper document on DB2 connection to DB Exploerer. I could connect to oracle, not to DB2.

    Just experimenting… until this gets resolved.

    Is someone seeing this thread.

    #256773 Reply

    Haris Peco
    Member

    modha,

    You use type 2 driver and this driver use native libraries (dll on windows). Java can’t load native libraries twice (in 2 classloaders) and this is your problems ;

    – you can’t redefine type 2 driver without restart eclipse (when you click Edit you will got error) – you have to remove driver, restart eclipse and define it again
    When you define driver correct once it will work fine.
    You haven’t to add drivers’ dll in MyEclpse – dll have to be in system path (windows’ system32 directory)

    However, type 2 drivers are very hard for settings and they works in local environment only.
    It is better that you try type 4 driver (pure java) – try IBM Db2 universal driver – code is same for type 2 and type4 and different is url specification only.For your case url is
    jdbc:db2://<YOUR_HOST>:<YOUR_PORT>/test , for type 4 and jdbc:db2:test for type 2

    Both work in MyEclipse, but you can’t redefine type 2 driver without restart eclipse (this is for every type 2 driver)

    So I created the driver, added a connection. Right click open the connection it opens. However if I click on the + sign next to connected to test, I see nothing under it.

    You have permission problems probably
    Please, can you check log (Windows -Show View – Other – PDE Runtime – Error log) and paste contents here

    Thanks
    Peco

    #256818 Reply

    modha
    Member

    Thanks peco.
    There is only type2 driver in the Template dropdown.
    Please tell me how I can add type 4 driver.

    I have db2java.zip in sqllib\java directory.

    #256828 Reply

    Haris Peco
    Member

    modha ,

    You have IBM Db2 (app driver) and IBM Db2 (Universal driver)

    First is type 4, but other can be type 2 or type (it depend from url.You can make some driver form template – template are only example

    I advice you that look on Db2 Unversal jdbc driver on ibm site – it is new and very good driver

    Best
    Peco

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: DB2 DBExplorer — java.lang.UnsatisfiedLinkError

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