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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:47:11+00:00 2026-05-26T02:47:11+00:00

had several apps with jdbc and Oracle 10g. Now I´m changing the apps for

  • 0

had several apps with jdbc and Oracle 10g. Now I´m changing the apps for use c3p0. But I have some problems working with Oracle types.

I Have this Oracle type:

CREATE OR REPLACE
TYPE DATAOBJ AS OBJECT
(
  ID NUMBER,
  NAME VARCHAR2(50)
) 

And this Oracle function:

    CREATE OR REPLACE FUNCTION F_IS_DATA_OBJECT (datar in DATAOBJ) RETURN varchar2 IS
    tmpVar varchar2(150);
    BEGIN
        tmpVar := 'Data object:';
        if datar.id is not null then
            tmpVar := tmpVar || 'id=' || datar.ID;
        end if;

        if datar.name is not null then
            tmpVar := tmpVar || 'name=' || datar.name;
        end if;


    return tmpVar;          

   EXCEPTION
     WHEN NO_DATA_FOUND THEN
       NULL;
     WHEN OTHERS THEN
       RAISE;
END F_IS_DATA_OBJECT;

then I have a app in Java with c3p0 with next classes:
Dataobj.class to represent the object type:

    package c3p0pruebas.modelo;

import java.io.Serializable;

import java.sql.SQLData;
import java.sql.SQLException;
import java.sql.SQLInput;
import java.sql.SQLOutput;

public class Dataobj implements SQLData, Serializable {

    private String name;
    private Integer id;


    public Dataobj() {
    }

    public String getSQLTypeName() {
        return "DATAOBJ";
    }

    public void writeSQL(SQLOutput stream) throws SQLException {
        stream.writeInt(id.intValue());
        stream.writeString(name);
    }

    public void readSQL(SQLInput stream, String typeName) throws SQLException {
        id = new Integer(stream.readInt());
        name = stream.readString();
    }


    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }
    ... and its gets and sets ....

And the main class and main method:

Connection connection = DBConnectionManager.getInstance().getConnection("Mypool"); //I use a class to get connection
     CallableStatement cs = null;
     String error = "";
        try {
/*
//First I made a NativeExtractor of the connection, but the result is the same, I got it from Spring framework.            
//C3P0NativeJdbcExtractor extractor = new C3P0NativeJdbcExtractor();
            //OracleConnection newConnection = (OracleConnection) extractor.getNativeConnection(connection);

            //cs = (OracleCallableStatement) newConnection.prepareCall("{? = call F_IS_DATA_OBJECT(?)}");
*/
            //Creates the object
            Dataobj obj = new Dataobj();
            obj.setId(new Integer(33));
            obj.setName("myName");

            cs = connection.prepareCall("{? = call F_IS_DATA_OBJECT(?)}");

            cs.registerOutParameter(1, OracleTypes.VARCHAR);
            cs.setObject(2, obj);

            cs.execute();
            error = cs.getString(1);

            System.out.println("Result: " + error);

        } catch (SQLException e) {
            e.printStackTrace();
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            closeDBObjects(null,cs,null);
        }
     closeDBObjects(null, null, connection); //Close connection

The execution gets:

Data object: id=33.

I cant get the String (Varchar2) value, the name string.

With oracle arrays of object type, I have the same problem, It worked nice with JDBC. When I worked with Arrays, also, it hasn´t the string values:

//Here I use a NativeConnection ...
    Dataobj arrayOfData[] = new Dataobj[myDataObj.size()];
... //Makes the array of DataObj.
                ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("OBJ_ARRAY", newConnection);
            ARRAY arrayDatas = new ARRAY(descriptor, newConnection, arrayOfData);

//In this step, objects of arrayDatas haven´t the name string…

Thanks!!!

  • 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-26T02:47:12+00:00Added an answer on May 26, 2026 at 2:47 am

    OK, It finally works.

    Searching, We found out the answer:

    We change data definition in the database and now it works:

    CREATE OR REPLACE
    TYPE "DATAOBJ" AS OBJECT
    (
      vid NUMBER,
      vname NCHAR(50)
    )
    

    Thanks!

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

Sidebar

Related Questions

I have tried several things so far, but I haven't had much luck yet.
In my limited experience, I've been on several projects that have had some sort
I have had several contexts where table names or schemas were not hard-coded, but
Programming languages had several (r)evolutionary steps in their history. Some people argue that model-driven
I am very new to creating webservers - and I have had several goes
Ok, I'm now very confused. After my last question had several people comment about
I had used several ways to do some simple integer arithmetic in BASH (3.2).
I have had to do this several times, usually when trying to find in
I have been writing software for several decades now and these days everything is
I am working with flex for the last two years on some desktop apps.

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.