| 发表于:2007-05-21 22:21:00 楼主 |
挺简单的一个程序啊.sqlj编译出错的原因在哪里呢?请大牛帮忙 我用db2 udb 8.2 for windows + wsad 5.1, 这是我的代码,为什么编译都过不去呢? package u7.pro; import java.sql.*; import sqlj.runtime.*; import sqlj.runtime.ref.*; public class sample1 { static { try{ class.forname( "com.ibm.db2.jdbc.app.db2driver ").newinstance(); } catch(exception e) { system.out.println( "\n error loading db2 driver ...\n "); system.exit(1); } } public static string getfname(int employid){ string firstname = null; string userid = "db2admin "; string passwd = "applena "; try{ string url = "jdbc:db2:sample "; connection con = null; con = drivermanager.getconnection(url, userid, passwd); defaultcontext ctx = new defaultcontext(con); defaultcontext.setdefaultcontext(ctx); #sql{ select fname into :firstname from employeedetails where employeeid = :employeeid }; }catch (exception e){ system.out.println(e); } return firstname; } public static void main(string args[]){ system.out.println( "first name is " + getfname(1)); } } 错误信息是: sqlj 转换: sample1.sqlj:26.3-28.3: error: java 类型对于主机项 #1 无效。 总计 1 个错误. |
|
|
|
|