关于db2和jbuilder的问题

sheek 2003-10-24 11:43:58
我是一个db2的新手,没有用过db2,请问一下db2怎么和jubilder结合起来开发阿?
...全文
57 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
sheek 2003-10-28
  • 打赏
  • 举报
回复
谢谢各位!
因为我刚开始安装V4.0,我正在摸索当中。
jeallan 2003-10-27
  • 打赏
  • 举报
回复
class DB2Appl {

static {
try {
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
} catch (Exception e) {
System.out.println(e);
}
}

public static void main(String argv[]) {
Connection con = null; (2)

// URL is jdbc:db2:dbname
String url = "jdbc:db2:sample"; (3)

try {
if (argv.length == 0) {
// connect with default id/password
con = DriverManager.getConnection(url);
}
else if (argv.length == 2) {
String userid = argv[0];
String passwd = argv[1];

// connect with user-provided username and password
con = DriverManager.getConnection(url, userid, passwd); (4)
}
else {
System.out.println("Usage: java DB2Appl [username password]");
System.exit(0);
}

// retrieve data from the database
System.out.println("Retrieve some data from the database...");
Statement stmt = con.createStatement(); (5)
ResultSet rs = stmt.executeQuery("SELECT * from employee"); (6)

System.out.println("Received results:");

// display the result set
// rs.next() returns false when there are no more rows
while (rs.next()) { (7)
String a = rs.getString(1); (8)
String str = rs.getString(2);

System.out.print(" empno= " + a);
System.out.print(" firstname= " + str);
System.out.print("");
}

rs.close();
stmt.close();

// update the database
System.out.println("Update the database... ");
stmt = con.createStatement();
int rowsUpdated = stmt.executeUpdate("UPDATE employee
SET firstnme = 'SHILI' where empno = '000010'");(9)

System.out.print("Changed "+rowsUpdated);

if (1 == rowsUpdated)
System.out.println(" row.");
else
System.out.println(" rows.");

stmt.close();
con.close();
} catch( Exception e ) {
System.out.println(e);
}
}
}
jeallan 2003-10-27
  • 打赏
  • 举报
回复
1.设置好classpath.
2.调用例子
DB2Appl.java
wkliangsdqd 2003-10-27
  • 打赏
  • 举报
回复
study!
db2boy 2003-10-24
  • 打赏
  • 举报
回复
关键是将db2 jdbc driver(db2java.zip)加载到jbuilder中,其他的应该跟其他数据库没有什么区别

5,889

社区成员

发帖
与我相关
我的任务
社区描述
IBM DB2 是美国IBM公司开发的一套关系型数据库管理系统,它主要的运行环境为UNIX(包括IBM自家的AIX)、Linux、IBM i(旧称OS/400)、z/OS,以及Windows服务器版本
社区管理员
  • DB2
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧