rom db2admin.employee where empno = :str1 };
System.out.println("Received results:");
while (true) {
#sql { FETCH :cursor2 INTO :str2 };
if (cursor2.endFetch()) break;
System.out.print (" empno= " + str1);
System.out.print (" firstname= " + str2);
System.out.print ("");
}
cursor2.close();
// rollback the update
System.out.println("Rollback the update...");
#sql { ROLLBACK work };
System.out.println("Rollback done.");
}
catch( Exception e )
{
e.printStackTrace();
}
}
}
注:本程序采用JDBCODBC桥的方式访问数据库,必须配置ODBC数据源。