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();
|
Comments
Hi Parveen,
Do you have any error message?
Hi Krzysztof Kazmierczyk,