请大家帮帮我解决一个有关JDBC的问题,谢谢先 你是否设置了游标状态,可能是JDBC版本不支持!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我并没有设置游标状态呀,而且另一个程序中用JDBC访问数据库也没有问题 返回的ResultSet光标是指向第一条记录之前(第零条记录)的,要用next()方法使它指向第一条记录。 你用的是桥,需要在你的控制面板(ODBC管理)中设置一个连接。 to hesandy:是建立odbc系统数据源吗?可我已经建了 返回的ResultSet光标是指向第一条记录之前(第零条记录)的,要用next()方法使它指向第一条记录。 ResultSet rs=ps.executeQuery(); t1.setText(rs.getString("customerName")); t2.setText(rs.getString("customerAge")); t3.setText(rs.getString("customerAddress")); t4.setText(rs.getString("customerEmail")); t5.setText(rs.getString("customerPhone")); cn.close();我想代码应该是错在上面这些代码之中你取结果集的数据时,能否保证结果集一定存在?能否保证结果集记录一定为1?还有能否保证你取字段的顺序是否是按照数据库表的顺序来取的?因为你使用的是数据源的方式,所以这一切都必须注意。另外,取数据的时候,你必须添上(rs.next())才行,即改为: ResultSet rs=ps.executeQuery(); if(rs.next()) { t1.setText(rs.getString("customerName")); t2.setText(rs.getString("customerAge")); t3.setText(rs.getString("customerAddress")); t4.setText(rs.getString("customerEmail")); t5.setText(rs.getString("customerPhone")); } cn.close(); 哎呀,问题终于解决了,折磨我好长时间了,谢谢大家了!我初学java不久,今后还请大家多多帮助!接分 一个排列问题 使用executor的一点疑惑 关于数组为参数的问题 如何获取局域网内全部服务器当前时间(Unix主机)? java applet能否访问同一HTML页面中的属性值 求设计思路 有谁知道ipworks.Smtp这个包吗?包括API,快帮帮小弟,我靠他找工作呢 请教!!!! 在线等,为什么我的代码原来可以运行,现在不可以了????TextPad 我编的坦克大战到底是什么问题 老是报错 代码都是从源码复制过来的 十万火急,谁能告诉我,powerdesigner是单独销售,还是在pb盘中?QQ:32243311 请问如何搜索在一个区域网内提供SQL数据库服务的服务器的名字?
是建立odbc系统数据源吗?可我已经建了
t1.setText(rs.getString("customerName"));
t2.setText(rs.getString("customerAge"));
t3.setText(rs.getString("customerAddress"));
t4.setText(rs.getString("customerEmail"));
t5.setText(rs.getString("customerPhone"));
cn.close();
我想代码应该是错在上面这些代码之中
你取结果集的数据时,能否保证结果集一定存在?能否保证结果集记录一定为1?还有能否保证你取字段的顺序是否是按照数据库表的顺序来取的?因为你使用的是数据源的方式,所以这一切都必须注意。
另外,取数据的时候,你必须添上(rs.next())才行,即改为:
ResultSet rs=ps.executeQuery();
if(rs.next()) {
t1.setText(rs.getString("customerName"));
t2.setText(rs.getString("customerAge"));
t3.setText(rs.getString("customerAddress"));
t4.setText(rs.getString("customerEmail"));
t5.setText(rs.getString("customerPhone"));
}
cn.close();
我初学java不久,今后还请大家多多帮助!接分