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

  • Home
  • SEARCH
  • 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 9009069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:05:57+00:00 2026-06-16T02:05:57+00:00

I have come across a strange behavior while executing a SELECT query using Statement#executeUpdate()

  • 0

I have come across a strange behavior while executing a SELECT query using Statement#executeUpdate() by mistake. While the Javadoc clearly states that executeUpdate() throws SQLException if the given SQL statement produces a ResultSet object. But when I’m executing SELECT * from TABLE_NAME, I don’t get any exception. Instead I’m getting an return value which is same as the no. of rows selected, if no. is less than or equal to 10. If the no. is more than 10, the return value is always 10.

Connection conn;
Statement stmt;
try {
    conn = getConnection();
    stmt = conn.createStatement();
    int count = stmt.executeUpdate("SELECT * from TABLE_NAME");
    log.info("row count: " + count);
} catch (SQLException e) {
    log.error(e);
    // handle exception
} finally {
    DbUtils.closeQuietly(stmt);
    DbUtils.closeQuietly(conn);
}

I am using Oracle 10g.

Am I missing something here or is it up to the drivers to define their own behavior?

  • 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-16T02:05:58+00:00Added an answer on June 16, 2026 at 2:05 am

    This behaviour is definetely contradicts Statement.executeUpdate API. What’s interesting,
    java.sql.Driver.jdbcCompliant API says “A driver may only report true here if it passes the JDBC compliance tests”. I tested oracle.jdbc.OracleDriver.jdbcCompliant – it returns true. I also tested com.mysql.jdbc.Driver.jdbcCompliant – it returns false. But in the same situation as you describe it throws

    Exception in thread "main" java.sql.SQLException: Can not issue SELECT via executeUpdate().

    It seems that JDBC drivers are unpredictable.

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

Sidebar

Related Questions

I have come across a strange behavior of Java that seems like a bug.
While analyzing some library code supplied by another company we have come across strange
I have come across a strange behavior with Microsoft Code Contracts that I don't
I have come across some strange behavior in my iPhone Objective-C app. I am
I have come across a strange scenario using the entity framework in the Where
Hi I have come across a strange problem.I have update the database using sqlite
We've come across something strange while developing our site . We have a collection
I have come across a very strange issue in python. (Using python 2.4.x) In
I have come across a strange behavior... In class A, at the viewDidLoad method
I have come across a strange defect. I am using Orbeon 3.9 CE on

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.