Results 1 to 5 of 5
  1. #1
    asgardar is offline Member
    Join Date
    Jan 2011
    Posts
    3
    Rep Power
    0

    Default Query taking lot of time to execute..

    Hi,
    I have a very complecated query which I am executing using JDBC. The query has an insert statement. This query takes 15 mins to complete. I'm running the query as stand alone java program. Can some one have some suggestions what is the best way to debug. I need to find out why the query is taking that long. I'm using oracle 10g with sql developer.

    ps = con.prepareStatement(query);
    ps.setString(1,date);
    ps.setString(2,code);
    timeStart = System.currentTimeMillis();
    ps.executeUpdate();
    timeEnd = System.currentTimeMillis();

    System.out.println("Time Taken::"+(timeStart -timeEnd)+" ms");

    Thanks in advance
    Ajoo

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    One single query or an entire set of queries. If a set, use addBatch and executeBatch, if a single query, then it can only be the network, or the db setup (bad keys/indexes or a very badly formed SQL statement), either one is not a Java problem.

  3. #3
    asgardar is offline Member
    Join Date
    Jan 2011
    Posts
    3
    Rep Power
    0

    Default

    One question, when I run the same query using SQL cosole or TOAD it finishes faster. does this mean something is wrong with my code?

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,453
    Blog Entries
    7
    Rep Power
    20

    Default

    Maybe changing this:

    Java Code:
    System.out.println("Time Taken::"+(timeStart-timeEnd)+" ms");
    to this:

    Java Code:
    System.out.println("Time Taken::"+(timeEnd-timeStart)+" ms");
    might help.

    kind regards,

    Jos ;-)
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

Similar Threads

  1. Replies: 3
    Last Post: 08-23-2011, 12:46 PM
  2. MySQl query taking too much time
    By jessie in forum JDBC
    Replies: 16
    Last Post: 11-11-2010, 01:09 PM
  3. time to execute a java app
    By svpranay in forum New To Java
    Replies: 6
    Last Post: 06-23-2010, 08:06 AM
  4. Taking a character off the end of a string.
    By AJArmstron@aol.com in forum New To Java
    Replies: 5
    Last Post: 05-05-2010, 02:56 AM
  5. Taking input from console
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-05-2007, 04:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •