Results 1 to 5 of 5
- 01-19-2011, 06:57 PM #1
Member
- Join Date
- Jan 2011
- Posts
- 3
- Rep Power
- 0
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
- 01-19-2011, 07:01 PM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
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.
- 01-19-2011, 07:06 PM #3
Member
- Join Date
- Jan 2011
- Posts
- 3
- Rep Power
- 0
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?
- 01-19-2011, 07:08 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,417
- Blog Entries
- 7
- Rep Power
- 17
Maybe changing this:
to this:Java Code:System.out.println("Time Taken::"+(timeStart-timeEnd)+" ms");
might help.Java Code:System.out.println("Time Taken::"+(timeEnd-timeStart)+" ms");
kind regards,
Jos ;-)When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 01-19-2011, 07:09 PM #5
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Similar Threads
-
JAVA Programmers Wanted - Full-Time and Part-Time Positions open
By javatrek2020 in forum Jobs OfferedReplies: 3Last Post: 08-23-2011, 12:46 PM -
MySQl query taking too much time
By jessie in forum JDBCReplies: 16Last Post: 11-11-2010, 01:09 PM -
time to execute a java app
By svpranay in forum New To JavaReplies: 6Last Post: 06-23-2010, 08:06 AM -
Taking a character off the end of a string.
By AJArmstron@aol.com in forum New To JavaReplies: 5Last Post: 05-05-2010, 02:56 AM -
Taking input from console
By Java Tip in forum Java TipReplies: 0Last Post: 11-05-2007, 04:47 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks