Home » Developer & Programmer » JDeveloper, Java & XML » Access Object type in Java class ?
Access Object type in Java class ? [message #143822] Sat, 22 October 2005 22:39
heguangm
Messages: 1
Registered: October 2005
Junior Member
Hi,

I have 5 oracle object types in oracle db, I created a table with 5 columns for them.

I can run sql to select them in plsql.

I created java classes, and wrote sql to retrieve them. it works for 4 types of them but not the 5th one.

I tried many scenarios, different type names, table names.

Does the type name have to the same as the java class name?

Here is my code to query the table: (I also attached the java class file)

sQuery = "Select * from SCNRT Where id = " + scnrid;
logger.log(Level.INFO, sQuery);


ors = (OracleResultSet) stmt.executeQuery(sQuery);
if(ors==null) logger.log(Level.INFO, "ors failed ...");

//should only 1 row returned
while (ors.next())
{

//get scnr id, should = 0
logger.log(Level.INFO, "Scnr ID: " + ors.getInt(1));

//get Demo parameters
s_demo = (Demo)ors.getORAData(2, Demo.getFactory());
//s_demo = (Demo)rs.getObject(2);
logger.log(Level.INFO, s_demo.toString());

//get Fw parameters
s_fw = (Fw)ors.getORAData(3, Fw.getFactory());
logger.log(Level.INFO, s_fw.toString());

//get Sim parameters
s_sim = (Sim)ors.getORAData(5, Sim.getFactory());
logger.log(Level.INFO, s_sim.toString());

//get Res parameters
s_res = (Res)ors.getORAData(6, Res.getFactory());
logger.log(Level.INFO, s_res.toString());
***** Code got stuck here for the last type *******
//get ThinScnr parameters: Japnese Larch
s_thinscnr = (ThinScnr)ors.getORAData(4, ThinScnr.getFactory());
logger.log(Level.INFO, "Start Age: " + s_thinscnr.startAge.intValue());
logger.log(Level.INFO, "after Init" + s_thinscnr.cycle.intValue());
logger.log(Level.INFO, "End Age: " + s_thinscnr.endAge.intValue());
logger.log(Level.INFO, "Try Getting: " + s_thinscnr.getCycle());


}

ors.close();
stmt.close();

}
catch(SQLException sqle)
{
logger.log(Level.INFO, "Problem Getting a scnr from WOW DB in Oracle" + ": " + sqle);
return -3;
}


The errors are:

oracle.sql.STRUCT@1123c5f
Oct 22, 2005 11:13:54 PM wol.WLUtils getScnr
INFO: marryAge: 22.0upperBirthAge: 48.0avgBirths: 2.5maleMarryOutRate: 0.043femaleMarryOutRate: 0.28maleBringFemalInRate: 0.043femaleBringMaleInRate: 0.19collegeRate: 1.92leaveHomeIntenRate: 42.0
oracle.sql.STRUCT@84de3c
Desc Type: FW
Subtype=false JavaObject=false FinalType=true
NUMBER
NUMBER
NUMBER
NUMBER
NUMBER

Desc Len: 5
StructDescriptor: new called
Oct 22, 2005 11:13:54 PM wol.WLUtils getScnr
INFO: ifNFCP: false pctFW4Heating2Ele: 80.0 pctFW4Heating2Ele: 80.0 pctFW4Cooking2Ele: 100.0 pctFW4Fodder2Ele: 0.0 pctLandReturned: 50.0
oracle.sql.STRUCT@1b3967
Oct 22, 2005 11:13:54 PM wol.WLUtils getScnr
INFO: startYear: 1996.0simYears: 5.0simTimes: 2.0enableGIS: false
oracle.sql.STRUCT@3bce70
Oct 22, 2005 11:13:54 PM wol.WLUtils getScnr
INFO: fwLayer: newfwnewHHLayer: newHHimpactedHSILayer: impHab
Creating:
oracle.sql.STRUCT@ec1f9e
Desc Type: THIN2
Subtype=false JavaObject=false FinalType=true
NUMBER
NUMBER
NUMBER
NUMBER

Desc Len: 4
1
10
60
3
StructDescriptor: new called
Session invalidated...
  • Attachment: ThinScnr.java
    (Size: 3.12KB, Downloaded 1584 times)
Previous Topic: Is there any way to set read timeout on JDBC connection ?
Next Topic: ERROR ON XML PARSING....IN ORACLE
Goto Forum:
  


Current Time: Fri Nov 22 09:39:07 CST 2024