Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7700299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:40:35+00:00 2026-05-31T22:40:35+00:00

So I wrote a method to just get a database table and it returns

  • 0

So I wrote a method to just get a database table and it returns the resultset. But, it seems to be hanging on this method call. I THOUGHT it was returning just a pointer but I’m still new to programming. Is this call returning a pointer of Resultset or is it passing the whole thing. My main question is, why would this slow down the program? The table isn’t that big.

public ResultSet getEmployeeTable() throws SQLException
{
    ResultSet rsEmpl;
    Connection con = getDBConnection();
    PreparedStatement pstmt;
    String query;

    query = "Select * from PTO_Employee where enabled = ?";
    pstmt = con.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
    pstmt.setInt(1, 1);
    rsEmpl = pstmt.executeQuery();      

    return rsEmpl;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:40:36+00:00Added an answer on May 31, 2026 at 10:40 pm

    It’s connecting the DB which takes the most time. This can last in range of 100ms up to 1 second. That’s also why most webapps are using a so-called connection pool. A connection pool contains a bunch of already-opened connections which the webapp can then just reuse. You’ll only need to rewrite your JDBC code to adhere the JDBC idiom of opening-and-closing in a try-finally block, otherwise you would later still have performance problems because you never return the connection to the pool and the pool would run out of them.

    Further, at the moment you’re returning the ResultSet, it does not contain any records in the memory. This will usually only be retrieved from the DB and filled in Java’s memory when you call next() for the first time. However, passing the ResultSet around outside the context where the SQL query is been invoked is a very bad practice. It should normally be mapped to a collection of entities.

    See also:

    • How often should Connection, Statement and ResultSet be closed in JDBC?
    • JDBC MySql connection pooling practices to avoid exhausted connection pool
    • Am I Using JDBC Connection Pooling?
    • Show JDBC ResultSet in HTML in JSP page using MVC and DAO pattern
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote this method to check if a page exists or not: protected bool
I wrote a method that extracts fields from an object like this: private static
I just wrote some new utility methods within a non-page class for an existing
I'm trying to write (or just find an existing) PHP method that can take
I have and old(ish) C# method I wrote that takes a number and converts
I'm having trouble with a method I wrote to insert string words into a
Using an idea from Bob King idea I wrote the following method. It works
Hello StackOverflow community, Using Google App Engine, I wrote a keyToSha256() method within a
I wrote a simple Util method to convert a String in Java to util.Date
I'm using Symfony 1.4 with Doctrine. Sorry if this is a silly question but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.