Accessing db2 from plugin project [message #256748] |
Tue, 20 May 2008 05:27 |
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.
please let me know is there any procedure to load the db2Driver class
while developing plugin project.
Code:-
-------
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
SEGMENT_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.
|
|
|
|
Re: Accessing db2 from plugin project [message #256822 is a reply to message #256787] |
Wed, 21 May 2008 06:51 |
Eclipse User |
|
|
|
Originally posted by: raguram.vidhyadharan.wipro.com
steps followed 3rd option
-------------------------
1)I created one plugin project (chosen the option Plug-in from
Existing JAR archives) by adding the db2 jars inside.
steps
------
*)In JAR selection window i selected the db2 jars through
Add External button
*)In plugin project properties window i just gave
'db2jars' as a plugin name and i clicked the
finish button.
*)I am able to see that all the db2 packages
(com.ibm.db2.jcc,com.ibm.db2.jcc.a,...) are listed in the
Exported packages box of Runtime tab in MANIFEST editor.
This is my MANIFEST.MF file content
-------------------------------
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Db2jars Plug-in
Bundle-SymbolicName: db2jars
Bundle-Version: 1.0.0
Bundle-ClassPath: .
Bundle-Localization: plugin
Export-Package: .,
com.ibm.db2.jcc,
com.ibm.db2.jcc.a,
com.ibm.db2.jcc.b,
com.ibm.db2.jcc.c,
com.ibm.db2.jcc.licenses,
com.ibm.db2.jcc.resources,
com.ibm.db2.jcc.sqlj,
com.ibm.db2.jcc.t2,
com.ibm.db2.jcc.t2zos,
com.ibm.db2.jcc.uw,
com.ibm.db2.jcc.uw.a,
com.ibm.db2.jcc.uw.classloader,
sqlj.runtime,
sqlj.runtime.error,
sqlj.runtime.profile,
sqlj.runtime.profile.ref,
sqlj.runtime.profile.util,
sqlj.runtime.ref,
sqlj.runtime.util
I exported this db2jars plugin project by
right clicking that folder -> export -> Deployable plugins and fragments
After exporting it i just opened that
db2jars_1.0.0(C:\ILOG\JRules661\studio\eclipse\plugins).It has all the
classes of my db2 jars.
2)I included this plugin project to my main plugin project by
including it in Required-plugins tab of Plugin.xml->Dependencies.
db2jars plugins are came inside Plugin-dependencies folder of my main
plugin project.
This is working fine when i run as standalone(from eclipse java editor if
i click control+click on the Class.forName("com.ibm.db2.jcc.DB2Driver") it
is referring the DB2Driver class from plugin dependencies).
*) 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")
Can you please let me know is this is correct or did i missed any steps.
Thanks & regards,
V.Raguram
|
|
|
Powered by
FUDForum. Page generated in 0.08577 seconds