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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:00:45+00:00 2026-06-10T05:00:45+00:00

im trying to execute a procedure which contains between others a parameter which is

  • 0

im trying to execute a procedure which contains between others a parameter which is a collection of object (oracle). I have managed them lot of times without spring, but I’m a bit lost trying to do it with spring, althoug there is some information on the internet, I can’t find a full example in order to compare my code. Spring doc has just fragments. Probably my code is wrong but i ignore why, could you help me? I’m running simplier procedures without problems. My DAO looks like this:

//[EDITED]
private SimpleJdbcCall pActualizaDia;

....

@Autowired
public void setDataSource(DataSource dataSource) {
  pActualizaDia = new SimpleJdbcCall(dataSource).withCatalogName("PTR_GRUPOS_TRABAJO").withProcedureName("UPDATE_DIA");
  pActualizaDia.getJdbcTemplate().setNativeJdbcExtractor(new OracleJdbc4NativeJdbcExtractor());
}
...

 public Calendario updateSingle(final Calendario calendario) {

    SqlTypeValue cambiosEmpresa = new AbstractSqlTypeValue() {

    protected Object createTypeValue(Connection conn, int sqlType, String typeName) throws SQLException {

    ArrayDescriptor arrayDescriptor = new ArrayDescriptor("TTPTR_CAMBIO_EMPRESA", conn);

    Object[] collection = new Object[calendario.getCambiosEmpresa().size()];
    int i = 0;
    for (CeAnoEmp ce : calendario.getCambiosEmpresa()) {
        collection[i++] = new STRUCT(new StructDescriptor("TPTR_CAMBIO_EMPRESA", conn), conn, new Object[] {
            ce.getSQLParam1(),
            //...more parameters here in order to fit your type.
            ce.getSQLparamn() });
    }

    ARRAY idArray = new ARRAY(arrayDescriptor, conn, collection);

    return idArray;

    }

};

     MapSqlParameterSource mapIn = new MapSqlParameterSource();
 mapIn.addValue("P_ID_ESCALA", calendario.getEscala().getIdEscala());
     //more simple params here

     //Here it is the Oracle ARRAY working properly
 pActualizaDia.declareParameters(new SqlParameter("P_CAMBIOS_EMPRESA",
 OracleTypes.STRUCT, "TTPR_CAMBIO_EMPRESA"));
 mapIn.addValue("P_CAMBIOS_EMPRESA",cambiosEmpresa);

     //When executing the procedure it just work :)
     pActualizaDia.execute(mapIn);
     return null;
   }

The exception I get sais

java.lang.ClassCastException: $Proxy91 cannot be cast to oracle.jdbc.OracleConnection

I’ve been reading more about this topic and i found that It almost seems like if using Oracle Arrays you also have to cast the connection to be an oracle connection.

However, most Spring jdbc framework classes like SimpleJDBCTemplate and StoredProcedure hide the connection access from you. Do I need to subclass one of those and override a method somewhere to get the dbcp connection and then cast it to an Oracle connection?

Thank you very much.

  • 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-10T05:00:47+00:00Added an answer on June 10, 2026 at 5:00 am

    I’ve solved it finally, I’ve edited the post in order to have an example for anyone looking for a piece of code to solve this issue.

    There are two important things to have in mind:

    1) It’s mandatory to set oracle extractor in jdbctemplate in order to cast properly the connection to get oracle functionality.

    2) When using this extractor ojdbc and JRE version must be the same, any other case you’ll get an abstractmethodinvocation exception.

    Thanks anyone who tried to solve it and hope it helps.

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

Sidebar

Related Questions

I'm trying to execute a stored procedure using ODBC which has a parameter, but
In my Script Component, am trying to execute Stored Procedure => which return multiple
I'm using an Oracle database(10g) which contains a stored procedure called Foo. Foo takes
I have a stored procedure in Oracle 9i which inserts records in a table.
I have been trying to make a stored procedure which autodeletes temporary tables. CREATE
I am trying to execute a sql script which creates a procedure and execute
So, I'm trying to use ODBC to execute a stored procedure in an SQL
I am trying to execute the following query in oracle but not able to
I'm trying to execute a stored procedure (against SQL Server 2005 through the ODBC
Im trying to execute a stored procedure and simply insert its results in a

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.