java - How to get Row count for sql select query taht not return any record and add that in ArraryList -


i have 1 problem in java programme when select record database,i need records not retrun sql query database. suppose have 5 record in table , give 8 record in condition in java programme need 3 record in arraylist programme did not retrun values..

my sample programme below:-

import java.sql.*; 

import java.util.arraylist; public class database {

   static final string jdbc_driver = "oracle.jdbc.driver.oracledriver";      static final string db_url = "jdbc:oracle:thin:@localhost:1521:orcl";      static final string user = "asiftest";    static final string pass = "asif";     public static void main(string[] args) {    connection conn = null;    statement stmt = null;    try{        class.forname("oracle.jdbc.driver.oracledriver");          conn = drivermanager.getconnection(db_url,user,pass);       arraylist ar =new  arraylist();        system.out.println("creating statement...");       stmt = conn.createstatement();       string sql;       sql = "select contractno temp_survival contractno in ('77777','11111','22222','33333','44444','55555','66666','77777','363636','25252')";       resultset rs = stmt.executequery(sql);         while(rs.next()){            string first = rs.getstring("contractno");           system.out.print("contractno: " + first);        }        rs.close();       stmt.close();       conn.close();    }catch(sqlexception se){        se.printstacktrace();    }catch(exception e){        e.printstacktrace();    }finally{        try{          if(stmt!=null)             stmt.close();       }catch(sqlexception se2){       }       try{          if(conn!=null)             conn.close();       }catch(sqlexception se){          se.printstacktrace();       }    }  } } 

for above programme getting values '77777','11111','22222','33333','44444','55555','66666','77777' next 2 records '363636','25252' not getting values because not available in database table need add them in arraylist in above proramme. please me

  1. make list input contact numbers (which passing in clause)
  2. make list of contact numbers getting in query results
  3. use collectionutils.substract(list1, list2)

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -