Unable to connect to DB2 database using server side plugin in rtc
Hi,
I have written a server side plugin (operation advisor)in which I am trying to connect to DB2 database and update values in database.
But I am not getting any connection to db2 database.
I have added db2jacc.jar and db2jcc_license_cu.jar to runtime in Manifest.mf file of plugin project.
Following is my code snippet for connecting to db2:
Object data = operation.getOperationData();
if (data instanceof ISaveParameter) {
// Get state of auditable item
ISaveParameter saveParameter = (ISaveParameter) data;
IAuditable auditable = saveParameter.getNewState();
// If everything is correct, the auditable is an WorkItem
if (auditable instanceof IWorkItem) {
IWorkItem newWorkItem = (IWorkItem) auditable;
try{
Class. forName ( "COM.ibm.db2os390.sqlj.jdbc.DB2SQLJDriver" );
Connection connection = DriverManager.getConnection("jdbc:db2://localhost:50000/CCM","username","password");
String str = " select * from tablename";
Statement stmt=connection.createStatement();
ResultSet rs=stmt.executeQuery(str);
while(rs.next()) {
String str1=rs.getString(1);
System.out.print(str1+" "+"\n");
}
//Update value of ID
PreparedStatement stmt1=connection.prepareStatement("tablename set id=id + 1");
int i=stmt1.executeUpdate();
//System.out.println(i+" records updated");
connection.close();
|
One answer
so that means probably one of these two statements failed
Class. forName ( "COM.ibm.db2os390.sqlj.jdbc.DB2SQLJDriver" );
Connection connection = DriverManager.getConnection("jdbc:db2://localhost:50000/CCM","username","password");
did u debug it to find out why? did the db2 driver jar get loaded to the plugin jar lib folder after build? that is where my extra jar files are for one of my plugins Comments
Parveen Patel
commented Jun 12 '15, 6:47 a.m.
Hi Sam,
I have imported the required jar files in meta.inf folder in plugin project and after that I have added that to my plugins manifest.mf runtime.
These are the steps which have followed to add DB2 jar files.
Please,guide me on this.
Thanks in advance
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.
Comments
Hi Parveen,
Do you have any error message?
Hi Krzysztof Kazmierczyk,