| 
| Problem while accessing db2 from plugin project [message #328272] | Tue, 20 May 2008 11:28  |  | 
| Eclipse User  |  |  |  |  | Originally posted by: raguram.vidhyadharan.wipro.com 
 Hi,
 These are the ways i have tried to connect db2. But i am not able to
 populate the data from db while running as a plugin project.
 
 1) import com.ibm.db2.jcc.DB2Driver;
 DB2Driver.getMyClassLoader();
 
 (or)
 
 Class.forName("com.ibm.db2.jcc.DB2Driver");
 
 I put the needed db2 jars(db2jcc.jar,db2jcc_license_cu.jar) in build path
 of the project folder.This is working fine(populating the data from db)
 when i run as standalone application. when we export our project folder as
 plugin project the db2 jars are not getting exported inside plugin
 project. I am getting NoClassDefFoundError in rule editor when i try to
 populate dynamic population window (while pressing ctrl+space).
 
 
 2) I added the needed db2 jars in Classpath tab of Plugin.xml->Runtime.
 This also not working. The db2 jars are getting exported into plugin
 project.Even i am getting
 NoClassFound error com.ibm.db2.jcc.DB2Driver.
 
 3) I created one more plugin project (chosen the option Plug-in from
 Existing JAR archives) by adding the db2 jars inside. Exported it as
 plug-in project.
 I included this plugin project to my main plugin project by including it
 in Required-plugins tab of Plugin.xml->Dependencies.
 db2jars are came inside Plugin-dependencies folder of my plugin project.
 This is working fine when i run as standalone.
 *) After exporting to plugin project i am getting NoClassDefFoundError
 if i use these statements import com.ibm.db2.jcc.DB2Driver;
 DB2Driver.getMyClassLoader()) for connecting db.
 *) After exporting to plugin project i am not getting any error in rule
 editor
 if i use Class.forName("com.ibm.db2.jcc.DB2Driver") for connecting db. But
 the data are not populated from db.The execution is not going after this
 statement Class.forName("com.ibm.db2.jcc.DB2Driver")
 
 4) I added the db2 jars in java system library.This is also not working
 after exporting plugin project.
 
 
 Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
 Connection con =
 DriverManager.getConnection("jdbc:db2://10.113.145.20:50000/db_CD1",
 "username", "password");
 stat =
 con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSe t.CONCUR_READ_ONLY);
 resultSet = stat.executeQuery("SELECT SEGMENT_TYP_ID,SEGMENT_TYP FROM
 ECOM_SCH.TSEGMENT_TYP")
 
 The same code is running fine while running as a standalone application.
 DB2Driver class is getting loaded .
 
 But this is not working after deploying as a plugin project.
 
 
 please let me know is there any procedure to load the db2Driver class
 while developing plugin project.
 |  |  |  | 
|  | 
|  | 
| 
| Re: Problem while accessing db2 from plugin project [message #328373 is a reply to message #328272] | Fri, 23 May 2008 10:11  |  | 
| Eclipse User  |  |  |  |  | i went through the your first mail again. having a separate plugin to contain the db2 jars (option 3) is the one that I would recommend. Use the
 "plugin from existing jar archives" option to create the plugin.
 
 Every eclipse plugin would have its own class loader. changing anything in
 the system classpath would not affect the plugin class loader, rather it
 would take its class path from the .manifest file  "Bundle-ClassPath:"
 parameter.
 
 Since you mentioned that you have the main plugin which has the db2 plugin
 as its dependency, the classpath of the main plugin would be the classpath
 of itself + classpath of the dependent plugin
 
 All said and done, sometimes the plugin classpath would have problems
 because of the build.properties file.
 
 your db2 plugin build.properties should atleast have something like this
 
 bin.includes = META-INF/,\
 com/,\
 javax/,\
 
 .......
 .......
 
 the com/ is the one you would be interested (DB2 packages would be
 com.ibm....)
 
 also look into the .log file in the workspace. that would give you a
 better idea of what the problem is.
 
 
 -Jeevan
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.25032 seconds