当前位置: 技术问答>java相关
用尽的resultset!!!!怎么解决?喷血求救!!!!
来源: 互联网 发布时间:2015-07-14
本文导语: String url="jdbc:oracle:oci8:xwrz/xwrz@oracle"; //加载驱动程序 Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=DriverManager.getConnection(url); Statement stmt=con...
String url="jdbc:oracle:oci8:xwrz/xwrz@oracle";
//加载驱动程序
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection(url);
Statement stmt=con.createStatement();
ResultSet rs;
//关联代码表
//String AUTITECOD="3";
rs=stmt.executeQuery("SELECT ID FROM AUTHITECOD WHERE AUTHITECOD.AUTHITE='"+AUTITE+"'");
rs.next();
String AUTITECOD=rs.getString("ID");
rs.close();
ResultSet rs1=stmt.executeQuery("SELECT ID FROM PROVCODE WHERE PROVCODE.PROVNAM='"+PRV+"'");
rs1.next();
String PRVCOD=rs1.getString("ID");
rs1.close();
ResultSet rs2=stmt.executeQuery("SELECT ID FROM SCHINFO WHERE SCHINFO.SCHNAM='"+SCHNAM+"'");
rs2.next();
String SCHNAMCOD=rs2.getString("ID");
rs2.close();
ResultSet rs3=stmt.executeQuery("SELECT ID FROM REPSTYLECODE WHERE REPSTYLECODE.REPSTY='"+REPSTY+"'");
rs3.next();
String REPSTYCOD=rs3.getString("ID");
rs3.close();
每次提示都用尽的resultset是什么意思
//加载驱动程序
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection(url);
Statement stmt=con.createStatement();
ResultSet rs;
//关联代码表
//String AUTITECOD="3";
rs=stmt.executeQuery("SELECT ID FROM AUTHITECOD WHERE AUTHITECOD.AUTHITE='"+AUTITE+"'");
rs.next();
String AUTITECOD=rs.getString("ID");
rs.close();
ResultSet rs1=stmt.executeQuery("SELECT ID FROM PROVCODE WHERE PROVCODE.PROVNAM='"+PRV+"'");
rs1.next();
String PRVCOD=rs1.getString("ID");
rs1.close();
ResultSet rs2=stmt.executeQuery("SELECT ID FROM SCHINFO WHERE SCHINFO.SCHNAM='"+SCHNAM+"'");
rs2.next();
String SCHNAMCOD=rs2.getString("ID");
rs2.close();
ResultSet rs3=stmt.executeQuery("SELECT ID FROM REPSTYLECODE WHERE REPSTYLECODE.REPSTY='"+REPSTY+"'");
rs3.next();
String REPSTYCOD=rs3.getString("ID");
rs3.close();
每次提示都用尽的resultset是什么意思
|
大概是rs结果集没有内容,造成rs3.getString("ID"); 取不出数据,报用尽的resultset,即结果集指针到达结尾,用尽的结果集。
你最好用
String REPSTYCOD="";
if(rs.next()){
REPSTYCOD=rs3.getString("ID");
}
就不会报错误了。
你最好用
String REPSTYCOD="";
if(rs.next()){
REPSTYCOD=rs3.getString("ID");
}
就不会报错误了。
|
你把变量定义在if之前
|
不判断指针是否到最后一条记录怎么行??
while(rs.next()){
REPSTYCOD=rs3.getString("ID");
}
try it!
while(rs.next()){
REPSTYCOD=rs3.getString("ID");
}
try it!