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
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
Krzysztof Kaźmierczyk
Jun 12 '15, 6:10 a.m.Hi Parveen,
Do you have any error message?
Parveen Patel
Jun 12 '15, 6:39 a.m.Hi Krzysztof Kazmierczyk,