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 8015369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:14:20+00:00 2026-06-04T20:14:20+00:00

My question : I’m wondering why the results from a query from a prepared

  • 0

My question: I’m wondering why the results from a query from a prepared statement should be inconsistent per run.

Warning weird stuff ahead.

I’m on an Oracle database. I’m using the ojdbc6.jar driver. I have a query which returns about 1300 rows (it changes over time because there’s a where clause which depends on sysdate). When I run it in Toad (SQL Developer tool) and Netbeans Services tool (Another interface with the database) it works great. My results are consistant. But when I run the query in java code my results are highly inconsistent. In an effort to try and see how frequent each result count returned I put it into a for loop and iterated 10 times. There is a relatively consistent row count within each run, but not across runs. My output and code are below. Let me know whether any more information is helpful.

When an attempt works (sorta…):

Got real queries (1308)
Got real queries (1308)
Got real queries (1308)
Got real queries (1307)
Got real queries (1307)
Got real queries (1317)
Got real queries (1317)
Got real queries (1317)
Got real queries (1317)
Got real queries (1315)

When an attempt does not work:

Got real queries (212)
Got real queries (212)
Got real queries (212)
Got real queries (212)
Got real queries (212)
Got real queries (212)
Got real queries (212)
Got real queries (212)
Got real queries (212)
Got real queries (212)

My code:

public static void main(String[] args) throws Exception {
  for (int i = 0; i < 10; i++) {
    List<String> realQueries = new ArrayList<>();
    String sqlAllRealQueries = "select V.SQL_FULLTEXT" + StringHelper.newline
            + "from v$sql v" + StringHelper.newline
            + "where V.PARSING_SCHEMA_NAME = 'DSS1_PTC'" + StringHelper.newline
            + "and to_number(replace(replace(replace(v.last_load_time,'-',''), '/',''), ':','')) > to_number(to_char(sysdate - (24/24),'yyyymmddHH24mmss'))" + StringHelper.newline
            + "order by V.LAST_LOAD_TIME desc";
    try (ResultSet rs = getInstance().executeQuery(sqlAllRealQueries)) {
      while (rs.next()) {
        realQueries.add(rs.getString(1));
      }
    }

    System.out.println("Got real queries (" + realQueries.size() + ")");
  }
  System.exit(0);
}

public ResultSet executeQuery(String connection, String query, QueryParameter... params) throws DataException, SQLException {
  Connection conn = ConnectionPool.getInstance().get(connection);
  PreparedStatement pstmt = conn.prepareStatement(query);
  for (int i = 1; i <= params.length; i++) {
    //... stuff to fill in the '?'s of the query (in this case, there are none).
    }
  }

  ResultSet rs = pstmt.executeQuery();
  ConnectionPool.getInstance().release(conn);
  return rs;
}
  • 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-06-04T20:14:22+00:00Added an answer on June 4, 2026 at 8:14 pm

    You have small bug in date format ‘yyyymmddHH24mmss’, should be ‘yyyymmddHH24miss’ (“mi” instead of “mm”)
    mm means month, minutes are “mi”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question: I want to test an if statement in PostgreSQL: IF (SELECT COUNT(*) FROM
Question from Object-Oriented JavaScript book: Imagine Array() doesn't exist and the array literal notation
Question: What is the standard method for accessing back end data, which logon should
Question mark I'm wondering whether it's possible for the VM guest machine to pop
Question should be self explanatory. I have a datagridview which has a column whose
Question: Considering the hello-gl2 example from Android NDK r6b, is this example correct when
Question: I want to populate a LINQ table from code, not DataBase. Is it
Question: In the UNIONized query below, how can I force @col to be assigned
[Question moved in from askubuntu.com] I'd like to get into Ubuntu systems programming; to
Question: Is there anyway at all to get an OpenGL context from GLUT? Info:

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.