当前位置: 技术问答>java相关
关于查询是否可以嵌套(近来看,没那么简单哦)
来源: 互联网 发布时间:2015-09-01
本文导语: 一个导航菜单,主菜单动态生成,每个主菜单的子菜单根据主菜单确定,也是动态生成,。如下: Connection con=cm.getConnection(); Statement stmt=con.createStatement(); String sql="select XT_CDJG.CDBT from XT_CDJG where XT_CDJG.FC...
一个导航菜单,主菜单动态生成,每个主菜单的子菜单根据主菜单确定,也是动态生成,。如下:
Connection con=cm.getConnection();
Statement stmt=con.createStatement();
String sql="select XT_CDJG.CDBT from XT_CDJG where XT_CDJG.FCD_ID='"+danweiid+"'";
ResultSet rs=stmt.executeQuery(sql);
int i=0;
%>
运行后生成一个主菜单及其子菜单后就停止了,其他的主菜单及子菜单没有
想问这样嵌套使用 rs.next() 可以吗???是不是这个有问题。有其他更好的生成这种菜单的办法吗?
Connection con=cm.getConnection();
Statement stmt=con.createStatement();
String sql="select XT_CDJG.CDBT from XT_CDJG where XT_CDJG.FCD_ID='"+danweiid+"'";
ResultSet rs=stmt.executeQuery(sql);
int i=0;
%>
运行后生成一个主菜单及其子菜单后就停止了,其他的主菜单及子菜单没有
想问这样嵌套使用 rs.next() 可以吗???是不是这个有问题。有其他更好的生成这种菜单的办法吗?
|
你在查询过程中使用了同一个Statement对象,另外创建一个肯定成功。
The object used for executing a static SQL statement and returning the results it produces.
By default, only one ResultSet object per Statement object can be open at the same time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. All execution methods in the Statement interface implicitly close a statment's current ResultSet object if an open one exists.
The object used for executing a static SQL statement and returning the results it produces.
By default, only one ResultSet object per Statement object can be open at the same time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. All execution methods in the Statement interface implicitly close a statment's current ResultSet object if an open one exists.