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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:58:15+00:00 2026-05-31T08:58:15+00:00

Anyone know what could be causing the following RUN TIME error in my Java

  • 0

Anyone know what could be causing the following RUN TIME error in my Java program trying to access an Oracle database on a different Linux server?

java.lang.ClassCastException : com.sun.gjc.spi.jdbc40.CallableStatementWrapper40 cannot be cast to oracle.jdbc.OracleCallableStatement

I was following the discussion/example on page 4-14 to 4-15 in Oracle’s JDBC Developer Guide ( http://isu.ifmo.ru/docs/doc112/java.112/e10589.pdf ). I created something similar to that example and it worked fine. Then I started modifying it to get to the below code AND introduced GlassFish into the process, and now I get that error.

Here’s my Java code:

public List<Report> GetReports(String var1, String var1, String var3) throws Exception {
    Connection conn;
    CallableStatement cs;
    ResultSet rset;
    String out1; 

    Context context = new InitialContext();
    DataSource ds = (DataSource)context.lookup("jdbc/myPool");
    conn = ds.getConnection();

    cs = conn.prepareCall( "{call my_proc (?,?,?,?,?)}" );

    cs.setString(1, var1);
    cs.setString(2, var2);
    cs.setString(3, var3);

    cs.registerOutParameter(4, Types.VARCHAR);
    cs.registerOutParameter(5, OracleTypes.CURSOR);

    cs.execute();

    out1 = cs.getString(4); 

    List<Report> userReports = new ArrayList<Report>();

    rset = ((OracleCallableStatement)cs).getCursor(5);
    while ( rset.next() ) {
        Report report = new Report();
        report.col1 = rset.getString("myCol1");
        report.col2 = rset.getString("myCol2");
        userReports.add(report);
    }

    if ( rset != null ) {
        try { rset.close(); } catch ( Exception ex ) {}
        rset = null;
    }

    if ( conn != null ) {
        try { conn.close(); } catch ( Exception ex ) {}
        conn = null;
    }

return userReports;
}
  • 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-31T08:58:17+00:00Added an answer on May 31, 2026 at 8:58 am

    There’s probably more than one way to solve this, but the following change to the above code works for me. Replace this statement:

    rset = ((OracleCallableStatement)cs).getCursor(5);
    

    with this statement:

    rset = (ResultSet) cs.getObject(5);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know a reason why my programs could be causing my speakers to
does anyone know where I could find the source code for the SandPile (cellular
Anyone know of a nice efficient function that could convert, for example: HelloWorld -->
Does anyone know of an algorithm that I could use to find an interesting
Does anyone know of an application (hosted or otherwise) that I could use to
Does anyone know of a PDF file parser that I could use to pull
Does anyone know of a quick color picker widget that I could grab to
My Page [0] text isn't centered on my webpage. Anyone know why? I could
The following program turns off the monitor. It sometimes crashes when I run it,
It isn't really causing a problem but it is annoying me... Does anyone know

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.