osimer pothe
osimer pothe

Reputation: 2897

rs.getInt(1) not working properly

I have the following syntax in SQL.

select Count(*) from queue_in_progress where CATEGORY_PK = 100001 AND SERVICE_STATUS = 0  AND SERVICE_CENTER_PK = 100001 AND SERVICE_COUNTER = 100001 ;

After this I got the following scenario .

enter image description here

But in my Java file I have the following code.

String sql="select Count(*)  from queue_in_progress where CATEGORY_PK = "+ ctgry_pk  
                        + "AND SERVICE_STATUS = 0  AND SERVICE_CENTER_PK = "+service_center+
                        " AND SERVICE_COUNTER = "+service_counter+" ;";

                rs =  getSeletRS(sql);
                int  count = rs.getInt(1);

Here I have got the following exception.

Exception in thread "main" java.lang.NullPointerException
    at dbquery.SQLQuery.get_TOKEN_Pk(SQLQuery.java:160)
    at dbquery.SQLQuery.clickNextButton(SQLQuery.java:131)
    at dbquery.SQLQuery.main(SQLQuery.java:388)

I cannot understand why I got this error.

Upvotes: 0

Views: 987

Answers (1)

Vicky Thakor
Vicky Thakor

Reputation: 3916

You need to check that your ResultSet is not null.

rs =  getSeletRS(sql);
if(rs  != null){
   int  count = rs.getInt(1);
}

Upvotes: 2

Related Questions