Reputation: 2897
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 .
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
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