DB2数据库、事务控制语言、系统控制语言、函数、嵌入式SQL(SQLJ) (二)

2014-11-23 21:58:54 · 作者: · 浏览: 21
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数据源。