DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2004
    Posts
    3

    JDBC ResultSet.getArray

    Hi All,
    I am working on a performance critical application .I need to retrive Ids of thousands of employees and store them in String[] and some times in int[] .
    On testing my application using JProfiler I found that much of the processing time is being spend iterating over resultset.

    I am using the following kind of code

    List empList=new ArrayList();
    while(rs.next())
    {
    empList.add(rs.getString("emp_id"));
    }
    String[]empIds=(String[])empList.toArray(new String[0]);

    I found that getArray() method of resultset is useful but I am not finding a suitable driver for this.Also my application needs to support multiple databases like SQLServer ,Oracle and Postgresql
    Can any one help me in this .
    Thanks
    Regards Nitin

  2. #2
    Join Date
    Jun 2004
    Posts
    199
    Having just dealt with this issue - your problem is more likely with your cursor type. You might want to change the fetch size. Oracle drivers default to 10. I found that 500 to 1000 is better. At least for the situation I was in.

    If your application needs to support multiple dbs - check out Hibernate (http://hibernate.org/ ) or a JDO vendor. I like Hibernate.

  3. #3
    Join Date
    Sep 2004
    Posts
    3
    Hi ,
    I am not getting performance even after uisng fetch size.
    Can u sugget me drivers that support the getArray() method of resultset for SQLServer and Oracle
    Thanks

  4. #4
    Join Date
    Jun 2004
    Posts
    199
    I don't know of any that do. Mostly becuase I have not researched it because it was not needed.

    I doubt the slow down is in the resultset.get___ . I've used Oracle to return large numbers of objects. The slowness was in pulling the data. Not building the objects.

  5. #5
    Join Date
    Sep 2004
    Posts
    3
    Hi,
    Yes u are absolutely right.
    setFetchSize actually improved the performance my problem was mainly in retrieving data which was solved by optimizing the query
    Thanks for suggestion

  6. #6
    Join Date
    Jun 2004
    Posts
    199
    Excellent. Good call on the query too.

    Remember that the driver and cursor type and network all can affect how it performs.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links