Java application is taking long time compare than query browser to run the query. — oracle-tech

    Forum Stats

  • 3,702,035 Users
  • 2,239,551 Discussions
  • 7,835,727 Comments

Discussions

Java application is taking long time compare than query browser to run the query.

stsivaraj-JavaNetstsivaraj-JavaNet Posts: 16
edited March 2016 in Java Desktop Applications

Hi,

     I am getting big time difference when I run same query in query browser and in my application.  The query browser it took only 2 seconds to run the query. But in my application it is taking 20 seconds.

Actually, I am handling 12L records. I am using sql server database and used native SQL(JDBC) API in my application. I mean natve statement and resultSet API to fetch the record. I copied my code pieces here.

//------------------------ COUNT QUERY ------------------------------------

//It is taking 2 seconds in query browser but in my application takes 17 seconds

  try{

          String executeQry="select count(id) from temp where some condition";

         statement = m_jdbcConnection .prepareStatement(executeQry);

         resultSet = statement.executeQuery();

         while (resultSet.next()) {

            totalCount = resultSet.getInt(1);

        }

  } catch(Exception e){

        //

  } 

  

//------------------------ RESULTSET QUERY ------------------------------------

//It is taking 2 seconds in query browser but in my application takes 20 seconds

  try{

        String executeQry="select ID,NAME,... from temp where some condition";// I used rownumber to limit.

       statement = m_jdbcConnection.prepareStatement(executeQry,ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);

       resultSet = statement.executeQuery(); 

       while (resultSet.next()) {

            //PROCESS THE RESULTSET

       }

  } catch(Exception e){

  //

  } 

  Is there any mistake in my code to handle? or any logic I need to improve(Any Cache concept- Statement cache or ResultSet Cache).

  Please suggest me what are items I need to be care while handling large data(Java Level) 

Tagged:
This discussion has been closed.