- This topic has 4 replies, 2 voices, and was last updated 18 years, 6 months ago by
Haris Peco.
-
AuthorPosts
-
modhaMemberHi
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/-
modhaMemberI 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.
Haris PecoMembermodha,
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 2Both 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 hereThanks
Peco
modhaMemberThanks 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.
Haris PecoMembermodha ,
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 -
AuthorPosts