mysql - Before start of result set -
i want display data 2 tables in single jsp page. getting following error. can please explain error.
java.sql.sqlexception: before start of result set @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:1058) @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:972) @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:958) @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:903) @ com.mysql.jdbc.resultsetimpl.checkrowpos(resultsetimpl.java:854) @ com.mysql.jdbc.resultsetimpl.getstringinternal(resultsetimpl.java:5772) @ com.mysql.jdbc.resultsetimpl.getstring(resultsetimpl.java:5692) @ com.mysql.jdbc.resultsetimpl.getstring(resultsetimpl.java:5732) @ jsp_servlet.__userhome._jspservice(__userhome.java:149) @ weblogic.servlet.jsp.jspbase.service(jspbase.java:35) @ weblogic.servlet.internal.stubsecurityhelper$servletserviceaction.run(stubsecurityhelper.java:280) @ weblogic.servlet.internal.stubsecurityhelper$servletserviceaction.run(stubsecurityhelper.java:254) @ weblogic.servlet.internal.stubsecurityhelper.invokeservlet(stubsecurityhelper.java:136) @ weblogic.servlet.internal.servletstubimpl.execute(servletstubimpl.java:346) @ weblogic.servlet.internal.servletstubimpl.execute(servletstubimpl.java:243) @ weblogic.servlet.internal.webappservletcontext$servletinvocationaction.wraprun(webappservletcontext.java:3432) @ weblogic.servlet.internal.webappservletcontext$servletinvocationaction.run(webappservletcontext.java:3402) @ weblogic.security.acl.internal.authenticatedsubject.doas(authenticatedsubject.java:321) @ weblogic.security.service.securitymanager.runas(securitymanager.java:120) @ weblogic.servlet.provider.wlssubjecthandle.run(wlssubjecthandle.java:57) @ weblogic.servlet.internal.webappservletcontext.dosecuredexecute(webappservletcontext.java:2285) @ weblogic.servlet.internal.webappservletcontext.securedexecute(webappservletcontext.java:2201) @ weblogic.servlet.internal.webappservletcontext.execute(webappservletcontext.java:2179) @ weblogic.servlet.internal.servletrequestimpl.run(servletrequestimpl.java:1572) @ weblogic.servlet.provider.containersupportproviderimpl$wlsrequestexecutor.run(containersupportproviderimpl.java:255) @ weblogic.work.executethread.execute(executethread.java:311) @ weblogic.work.executethread.run(executethread.java:263)
update:
code, causing error
preparedstatement pstm = null; string sql = "select * owner"; pstm = con.preparestatement(sql); resultset rs = pstm.executequery(); resultset firstrs=rs; string tname=rs.getstring("tablename"); string sql1="select * "+tname; statement stmt=con.createstatement(); resultset rs1=stmt.executequery(sql1); resultsetmetadata rsmd=rs1.getmetadata();
preparedstatement pstm = null; string sql = "select * owner"; pstm = con.preparestatement(sql); resultset rs = pstm.executequery(); resultset firstrs=rs; string tname=""; while(rs.next())//you have write resultset because if result set empty gaves error { tname=rs.getstring("tablename"); tname+=","; } if(!tname.equal("")) { string sql1="select * "+tname;///it select multiple tables results statement stmt=con.createstatement(); resultset rs1=stmt.executequery(sql1); resultsetmetadata rsmd=rs1.getmetadata(); }
Comments
Post a Comment