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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:00:07+00:00 2026-05-16T16:00:07+00:00

I want to create a subclass that extends the CallableStatement object. I want to

  • 0

I want to create a subclass that extends the CallableStatement object. I want to do this so I can override the execute and executeQuery methods to track some metrics on each SP call.

Currently I have code that looks like this:

Connection db = poolingDataSource.getConnection();
CallableStatement cstmt = db.prepareCall("{call pSampleStoredProc()}");
ResultSet rs = cstmt.executeQuery();

where poolingDataSource is from the apache commons dbcp package. My implementation is hooked into a MySQL database using JDBC.

Currently, the prepareCall method returns a com.mysql.jdbc.JDBC4CallableStatement. I’d like to be able to change this so that it returns a class of my own that extends JDBC4CallableStatement but overrides the execute() and executeQuery() methods.

Any ideas about the best way to do this?

  • 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-16T16:00:08+00:00Added an answer on May 16, 2026 at 4:00 pm

    If you have a manageable number of places where you need to do this, I suggest an easy way to do it (easier than trying to get that database driver to return your custom CallableStatement object) would be to make a wrapper or decorator to wrap over the CallableStatement object you get from db. Basically make a class that implements all the methods of CallableStatement, takes a CallableStatement object as a parameter to its constructor, and delegates all the method calls right through to the other object, with the exception that for execute() and executeQuery() you also call your logging methods before and after delegating to the other objects execute() method.

    Certainly there are other ways to do this, this just struck me as easier.

    Connection db = poolingDataSource.getConnection();
    CallableStatement cstmt = db.prepareCall("{call pSampleStoredProc()}");
    MyCallableStatement mystmt = new MyCallableStatement( cstmt );
    ResultSet rs = mystmt.executeQuery();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a subclass of NSMutableArray and need to override the -initWithObjects:
How to create in C++ an abstract class with some abstract methods that I
i want to create a subclass of NSWindow . this subclass needs to initialize
I want to create an object that acts as a specific class, such as
I really want to create a subclass of FutureTask that has a default no-arg
I want to create a method in superclass of test-class that stubs some commonly
I am trying ebook reading app. In that I want create UIActionSheet by clicking
I want to create 5 variables of type array all at once. Is this
I want to create a set of classes that share a lot of common
Basically I want to create a method that has a signature like the following:

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.