Java SQL COUNT Value -



Java SQL COUNT Value -

i trying homecoming count value in attached java, have..

package com.example.tests; import java.awt.geom.generalpath; import java.sql.connection; import java.sql.drivermanager; import java.sql.resultset; import java.sql.sqlexception; import java.sql.statement; public class testnew { public void generateid(){ int count; seek { class.forname("com.microsoft.sqlserver.jdbc.sqlserverdriver"); connection conn = drivermanager.getconnection("jdbc:sqlserver://ip:port;databasename=blabla;integratedsecurity=true;"); system.out.println("connection successfull"); system.out.println(conn); //-------------------------------------------------------------------- statement stmt = conn.createstatement(); string query1= "select count(*) dbo.vsubscriberreporting [subscriberemailaddressstatusid] in (5,1,6,7) , [subscriberstatusid] = 1 , [subscriberaddresseestatusid] = 1 , companysizecodeid in (4)"; resultset rs= stmt.executequery(query1); count = rs.getint(1); //i cant store count value query in variable... please help me. } grab (classnotfoundexception e) { // todo auto-generated grab block e.printstacktrace(); } grab (sqlexception e) { // todo auto-generated grab block e.printstacktrace(); } } public static void main(string[] args) { testnew gen = new testnew(); gen.generateid(); } }

the query runs, comes with

com.microsoft.sqlserver.jdbc.sqlserverexception: result set has no current row.

though know there should data, single count record..

i able store result variable guess , utilize later verify field in selenium script?

call rs.next() before trying phone call getint(1)

if(rs.next()) //expecting 1 row. { count = rs.getint(1); }

java sql jdbc

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -