Working with Oracle Objects in JAVA - How-to do with views
Hello,
I am trying to access to Oracle object types from Java.
My problem is, I have relational tables, Object Types and Object Views.
All the examples I found from Oracle manuals are working with Object Tables(Table column is created as Object Type).
You run a query and get this object type (oraconn.GetObject(1)) and the query is (SELECT * FROM Object_Table) so its get first column(which is an object type) and cast it to Java Class(with SQLDATA or ORADATA).
The problem is that my data is in Relational Tables and I don't want to export them to Object tables.
I want to get it from Object View.
Is this possible? Or better is anybody has an example???
Thx in advance
Hi,
I think you will be able to help me. your question made me to think that you will be able to help me. Here the question goes.
I have a Stored Procedure which returns a user defined ROWTYPE(its a IN OUT param to the procedure). I need to call this procedure from my Java program. So I would like to know how to do it. Do we need to use any packages provided by oracle or some thing like that.
thanks & regards,
Anil.
[email protected]
Similar Messages
-
Working with Oracle Objects in JAVA - How to with views
Hello,
I am trying to access to Oracle object types from Java.
My problem is, I have relational tables, Object Types and Object Views.
All the examples I found from Oracle manuals are working with Object Tables(Table column is created as Object Type).
You run a query and get this object type (oraconn.GetObject(1)) and the query is (SELECT * FROM Object_Table) so its get first column(which is an object type) and cast it to Java Class(with SQLDATA or ORADATA).
The problem is that my data is in Relational Tables and I don't want to export them to Object tables.
I want to get it from Object View.
Is this possible? Or better is anybody has an example???
Thx in advanceHi,
I think you will be able to help me. your question made me to think that you will be able to help me. Here the question goes.
I have a Stored Procedure which returns a user defined ROWTYPE(its a IN OUT param to the procedure). I need to call this procedure from my Java program. So I would like to know how to do it. Do we need to use any packages provided by oracle or some thing like that.
thanks & regards,
Anil.
[email protected] -
HELP IN Creating customized Oracle Object from Java
How can I create a customized oracle object that has these 3 fields with data persistance:
NAME : VARCHAR2
INSER_DATE : DATE
OBJ:user-defined collection(oracle.sql.array)
using JAVA. Later, that oracle object is enqueue in Oracle avanced Queue.
I've been looking in this site for the answer but had no luck.
I am using Java 1.2 and Oracle 8.1.6.
Any help will be appreciated as I needed so badly. Thanks.
Robby
[email protected]Hi
I assume your attempting to generate a Java class with the approriate getters and setters. If so the JPulisher utility is what your after. You can access it from either JDeveloper or the command line... Its documented in the Oracle Java manuals (jdbc etc.)...
A piece of advice... especially if you using AQ and ADT's or oracle's jms implementation against AQ, make sure you use the Oracle 8.1.7 jdbc drivers, even if your accessing an 8.1.6 DBMS. The performance difference is significant
Dom -
How to use Oracle objects in java code
Hi all!
I'm reading an xls and i need to fill me oracle objects with java code:
OBJECT_NAME OBJECT_TYPE
LETTURA_OBJ TYPE
LETTURA_OBJ TYPE BODY
In the past weeks i've been using both java code into oracle and oracle objects, but new i need to write those objects with data i read with java, anybody can help me?
I know that the easiest work around would be to put the data i read from the excel file into a table and then fill the oracle objects, but now i want to learn how to write directly those objects with a command like the following one:
a sample of the code i'm tryng to write:
CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED REPORT."Manage_Excel_ASMBS" AS
import java.io.*;
import java.io.IOException;
import jxl.*;
public cass ....
#sql{ variabili_globali.var_ER_F3.Tipo_Lettura := 5}
thanks,
Massimo
Edited by: LinoPisto on 16-mag-2011 16.38mmmh i'm not understanding so much....
well... as i told before i'm working in oracle database environment and i'm developing a java procedure.
now, i have this object
CREATE OR REPLACE
TYPE REPORT.FATTURA_OBJ AS OBJECT (
POD VARCHAR2(1000),
ID_FATTURA NUMBER,
ID_FILE NUMBER,
COERENZA_EA_F VARCHAR2(1000),
COERENZA_ER_F VARCHAR2(1000),
COERENZA_EA_M VARCHAR2(1000),
COERENZA_EF_M VARCHAR2(1000),
ANOMALIA VARCHAR2(1000),
MOTIVO_INVALIDAZIONE VARCHAR2(1000),
MATRICOLA_CONTATORE VARCHAR2(1000),
POTENZA_DISPONIBILE VARCHAR2(1000),
MEMBER PROCEDURE pulisci
/and i need to work with it inside this procedure:
CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED REPORT."Manage_Excel_ASMBS" AS
import java.io.*;
import java.io.IOException;
import java.io.StringWriter;
public class Manage_Excel_ASMBS
public static void read_Excel(String inputFile,int var_Id_Caricamento, int var_Id_Distributore, String var_Distributore) throws SQLException, IOException
**here i need to put what i'm reading inside the excel file into oracle objects**
/can you please give me a sample ?
thanks -
Working with oracle object type tables
Hi,
I've created a table which only contains Oracle object types (e.g. CREATE TABLE x OF <...>). When I create an Entity for this table using the Entity wizard, I end up with an entity with the attributes of the base object type and two special attributes REF$ (reference to the object type instance) and SYS_NC_OID$ (unique object identifier). The REF$ attribute is on the Java side of type oracle.jbo.domain.Ref and the other attribute is on the Java side a simple String.
It seems this only allows me to save objects of the base type in this table. First of all in my situation this is also impossible because the base type is not instantiable. What I do want is to save several different subtypes into this table using the BC4J custom domain mechanism. Is there any way to make this possible? I first thought I could maybe do something with the special REF$ attribute, but this doesn't seem te case. So I might need to override most of the EntityImpl methods, like doUML, remove etc. Am I right? And does anyone have any hints on how to do this?
Regards,
PeterPeter:
Hi,
I've created a table which only contains Oracle
object types (e.g. CREATE TABLE x OF <...>).
When I create an Entity for this table using the
Entity wizard, I end up with an entity with the
attributes of the base object type and two special
attributes REF$ (reference to the object type
instance) and SYS_NC_OID$ (unique object identifier).
The REF$ attribute is on the Java side of type
oracle.jbo.domain.Ref and the other attribute is on
the Java side a simple String.
It seems this only allows me to save objects of the
base type in this table. First of all in my situation
this is also impossible because the base type is not
instantiable. What I do want is to save several
different subtypes into this table using the BC4J
custom domain mechanism. Is there any way to make
this possible? Sorry, but this is not supported out of the box.
Since you have an object table, you wouldn't use domains to achieve this. Instead, you would have a superclass and subclass entity objects, e.g., PersonEO subclassed into StudentEO and EmployeeEO.
I first thought I could maybe do
something with the special REF$ attribute, but this
doesn't seem te case. So I might need to override
most of the EntityImpl methods, like doUML, remove
etc. Am I right? And does anyone have any hints on
how to do this?
If you want, you can try this by overridding EntityImpl's:
protected StringBuffer buildDMLStatement(int operation,
AttributeDefImpl[] allAttrs,
AttributeDefImpl[] retCols,
AttributeDefImpl[] retKeys,
boolean batchMode)
and
protected int bindDMLStatement(int operation,
PreparedStatement stmt,
AttributeDefImpl[] allAttrs,
AttributeDefImpl[] retCols,
AttributeDefImpl[] retKeys,
HashMap retrList,
boolean batchMode) throws SQLException
Handle the case when operation == DML_INSERT.
There, build an insert statement with substitutable row, e.g.:
INSERT INTO persons VALUES (person_t('Bob', 1234));
INSERT INTO persons VALUES (employee_t('Joe', 32456, 12, 100000));
where person_t and employee_t are database types and you are invoking the respective constructor.
Thanks.
Sung -
Creating/Working With Nullable Objects in PowerShell - How?
Hi,
how do I create and work with Nullable objects in PowerScript.
None of the tips I found worked:
> ([System.Nullable[System.Int32]]1).GetType().Name
Int32
> ([System.Nullable[System.Int32]]$null).GetType().Name
You can't call a method on a null value expression.
> (New-Object System.Nullable[Int32] 1).GetType().Name
Int32
Any help is appreciated!Well, nullable: yes, but Nullable: no.
this is what I get in .NET if I call GetType() on a variable of type Nullable[Int32]:
int? a = null; a.GetType();
{Name = "Nullable`1" FullName = "System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"}
[System.RuntimeType]: {Name = "Nullable`1" FullName = "System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"}
base {System.Reflection.MemberInfo}: {Name = "Nullable`1" FullName = "System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"}
Assembly: {mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}
AssemblyQualifiedName: "System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Attributes: Public | SequentialLayout | Sealed | Serializable | BeforeFieldInit
BaseType: {Name = "ValueType" FullName = "System.ValueType"}
ContainsGenericParameters: false
DeclaringMethod: "(typeof(int?)).DeclaringMethod" hat eine Ausnahme vom Typ "System.InvalidOperationException" verursacht.
DeclaringType: null
FullName: "System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"
GenericParameterAttributes: "(typeof(int?)).GenericParameterAttributes" hat eine Ausnahme vom Typ "System.InvalidOperationException" verursacht.
GenericParameterPosition: "(typeof(int?)).GenericParameterPosition" hat eine Ausnahme vom Typ "System.InvalidOperationException" verursacht.
GUID: {9a9177c7-cf5f-31ab-8495-96f58ac5df3a}
HasElementType: false
IsAbstract: false
IsAnsiClass: true
IsArray: false
IsAutoClass: false
IsAutoLayout: false
IsByRef: false
IsClass: false
IsCOMObject: false
IsContextful: false
IsEnum: false
IsExplicitLayout: false
IsGenericParameter: false
IsGenericType: true
IsGenericTypeDefinition: false
IsImport: false
IsInterface: false
IsLayoutSequential: true
IsMarshalByRef: false
IsNested: false
IsNestedAssembly: false
IsNestedFamANDAssem: false
IsNestedFamily: false
IsNestedFamORAssem: false
IsNestedPrivate: false
IsNestedPublic: false
IsNotPublic: false
IsPointer: false
IsPrimitive: false
IsPublic: true
IsSealed: true
IsSecurityCritical: false
IsSecuritySafeCritical: false
IsSecurityTransparent: true
IsSerializable: true
IsSpecialName: false
IsUnicodeClass: false
IsValueType: true
IsVisible: true
MemberType: TypeInfo
Module: {CommonLanguageRuntimeLibrary}
Namespace: "System"
ReflectedType: null
StructLayoutAttribute: {System.Runtime.InteropServices.StructLayoutAttribute}
TypeHandle: {System.RuntimeTypeHandle}
TypeInitializer: null
UnderlyingSystemType: {Name = "Nullable`1" FullName = "System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"}
That's quite a difference to PowerShell's:
([System.Nullable[System.Int32]]$null).GetType()
You can't call a method on an expression with value NULL.
See my point? PowerShell apparently doesn't have a notion about Nullable types. That's what I need to find out for myself: "Why?"
Best regards,
Axel Dahmen -
Performance of mapping Oracle objects to Java classes
Hi,
By retrieving some test data from Oracle database in a Java application, I compared the traditional JDBC/RDBMS solution to JPublisher-generated-classes/Oracle-object-tables solution. The underlaying Oracle database and the client environment was the same in both tests. Although the table schemas were different, they represented the same data.
It seems that the traditional JDBC/RDBMS solution is much faster. Is this a reality or did I make a mistake somewhere?
BR,
TimoI am also facing performance overhead when using Jpub generated
classes for the object types.
I am using 817 jdbc and jpub but my database is 816. I have seen
that following statements each take around 2-3 seconds to
execute. Is there any communication between driver and database
to resolve the object type ?
Please help.
cCallableStatement =
(OracleCallableStatement)m_cConnection.prepareCall("{call
list_unsync_appts_array(?,?,?,?,?,?,?,?)}");
((OracleCallableStatement)cCallableStatement).setCustomDatum(1,ct_number_arr);
cCallableStatement.registerOutParameter(2,OracleTypes.ARRAY,"T_EVENT_SUMMARY_ARR");
cCallableStatement.registerOutParameter(3,OracleTypes.ARRAY,"T_EVENT_DETAIL_ARR");
cCallableStatement.registerOutParameter(4,OracleTypes.ARRAY,"T_EVENT_SUMMARY_ARR");
cCallableStatement.registerOutParameter(5,OracleTypes.ARRAY,"T_EVENT_DETAIL_ARR");
cCallableStatement.registerOutParameter(6,OracleTypes.ARRAY,"T_EVENT_SUMMARY_ARR");
cCallableStatement.registerOutParameter(7,OracleTypes.ARRAY,"T_ATTENDEE_EMAIL_ARR");
cCallableStatement.registerOutParameter(8,OracleTypes.ARRAY,"T_ATTENDEE_EMAIL_ARR");
cCallableStatement.execute(); -
Object Relational Mapping - How to? - With SQLJ? - What brings the future?
Hi there,
we are developing applications for masterdata
maintainance and masks with fast user interaction using a two-tier architektur and a layered java application on the client.
Currently we are using TOPLink for the ORM stuff.
As we need a simple and efficient way to encapsulate gui stuff from database interaction i am interessted in SQLJ for the descripted purpose.
These are my questions:
1. Can I use SQLJ with a Oracle database lower than 8i
2. Is there a runtime fee for SQLJ?
3. How does SQLJ relate to the app server
hpye?
4. Where can I get SQLJ?
5. Do I need JDeveloper in combination with SQLJ or can I use any other IDE?
Thanks for your input.
Regards,
Wolfgang Rothmayer.SQLJ is actually orthogonal to use of ORM. It is an embedded language API for (static) SQL database access in contrast to JDBC.
If you are using SQL Object types (Oracle 8i and later) then there is the JPublisher tool to map these into Java classes.
Oracle also provides the BC4J (Business Components for Java) product for object-relational access. This is used mostly in conjunction with JDeveloper.
So from an ORM perspective you would not be asking for SQLJ.
To the SQLJ-specific questions:
1. Yes. SQLJ relies on Oracle JDBC for database access. Oracle 7.2 and later can be accessed.
2. No.
3. SQLJ can be used in any tier - just like JDBC can.
4. In the OTN download area. It is also part of all Oracle database releases since 8.1.5.
5. SQLJ comes with a command line interface (similar to Javac). It is also directly supported in the Oracle server-side JavaVM, which has an integrated Java compiler and SQLJ translator.
IBM VisualAge for Java has added support for SQLJ. For other IDEs you would be on your own, though I have heard that JBuilder users have been able to integrate SQLJ in their IDE (if somebody sends us a recipe for using SQLJ in their favorite IDE, we'll be happy to include that in future distributions). SQLJ could be integrated either through the commandline, or -for tighter support- through its IDE interface package in sqlj.framework.ide. -
while building Entity bean with Container managed persistence
we will create a database schema file, which will allow us to map fields
from the enterprise beans to columns in the database tables created.
For creating database schema file using Sun java System Application Server 8.2 and oracle9i database for j2ee1.4, i issued the following command at the command prompt.
F:\j2eetutorial14\examples\ejb\cmproster>capture-schema -dburl jdbc:oracle:thin:@127.0.0.1:1521:oraglo -username scott -password tiger -table LEAGUE -table PLAYER -table TEAM -table TEAM_PLAYER -schemaname scott -driver oracle.jdbc.driver.OracleDriver -out build/cmproster.dbschema
The above command gives the following error message. How do i debug this error. Thanks in advance
using dburl:jdbc:oracle:thin:@127.0.0.1:1521:oraglo
using username:scott
using password:tiger
using driver:oracle.jdbc.driver.OracleDriver
using schemaname:scott
using output file:build/cmproster.dbschema
Capturing schema:scott
JDO71101: Cannot access table LEAGUE.
JDO71101: Cannot access table PLAYER.
JDO71101: Cannot access table TEAM.
JDO71101: Cannot access table TEAM_PLAYER.
JDO71102: No valid tables requested. No schema file createdhow to provide the JNDI name in Sun Java Application Server
Please do the favour
Please reply to [email protected] -
I need help with File Object in Java
Hello Experts.
I am learning Java 2 now. I have trouble with reading a JTextField and save it to a file. I have some errors that I dont know what they are. I would like someone please help me to write a short sample program to see how it work. The code from the book I have dont execute at all. And I want to use FileOutputStream and ObjectOutputStream. Thank you very much
Quocimport java.io.*;
public class FileTest {
public static void main(String[] arg) throws Exception{
FileOutputStream fileOut = new FileOutputStream("test.txt");
fileOut.write("Test file".getBytes());
fileOut.close(); -
Should I start with Entity Object or Java Class Diagram ??
Hi,
I come to J2EE / OO application development from non-oo programming world. I am still confused about what step-by-step development approach should I take ?
Should I :
- start with creating Entity Object from available database table ?
- should I start with Java class diagram, followed by generating database tables, then create EO from it ?
Could anybody please help me, what best practice step by step development approach should I take ?
Is there any white paper / docs about this ?
Thank you for your help,
KristKrist,
If you are not from the OO world then you may be interested in this new site on OTN (http://otn.oracle.com/formsdesignerj2ee) There is a workshop that starts by looking at an existing datamodel and builds up from there.
If you are starting from nothing, you can indeed start higher at the Class Model level.
I recently started discussing data modeling on my blog (http://www.groundside.com/blog/content/SueHarper/) and there are some very good comments(feedback from readers) that may possibly be useful to you.
If you are new to the UML modeling world, I recommend you read two very good papers by Jan Kettenis on OTN (http://www.oracle.com/technology/products/jdev/collateral/collateral10g.html) They are Getting Strted with UML Class modeling and Getting Started with UML Use Case Modeling.
Shay pointed you to Toplink. There are a lot of resources on OTN for Toplink, including tutorials.
Personally? I think if you have time, and if you can, start with a Class Model and perhaps a Use Case model, then you can start planning your application development from a solid base.
Regards
Sue Harper -
JPA Object-Relational Mapping: how to deal with self-related mapping?
ignore the post.
sorry for my stupidity
==
Hello,
Suppose I have a class nemed Group, which can have sub-groups. It is defined like:
@Entity
Class Group{
private int id;
private String name;
private Group parent; //M-1 mapping
The problem is Group is mapped to itself:
child group -- parent group
M : 1
How JPA supports that kind of relationship? Can I put both
@Many-to-One and @One-to-Many over parent field like:
@Many-to-One
@One-to-Many
private Group parent;
Thanks a lot!
Message was edited by:
javasprinterOne possibility could be the following - (included annotation mappings):
@Entity
Class Group{
private int id; // probably should change to Integer to account for null data
private String name;
@ManyToOne
@JoinColumn(name = "PARENT_GROUP_FK")
private Group parent; //M-1 mapping
@OneToMany
@JoinTable ( name = "SUB_GROUPS",
joinColumns = { @JoinColumn(name = "PARENT_GROUP_ID")},
inverseJoinColumns = {@JoinColumn(name = "CHILD_GROUP_ID")}
private List subGroups;
Tables -
Group - columns - id, name, parent_group_fk
Sub_groups - columns - parent_group_id, child_group_id
The above maps a unidirectional relationship from parent group to child groups, but that really isn't a big deal because you can always get the parent from the parent group id.
I'm sure this isn't the best way, but it worked for me. HTH. -
Can i work with oracle 10g express edition by connecting it with visuval studio 2010?
i have oracle 10g-express edition,and visuval studio 2010, can i have a connectivity between these two?or it requires any additional installations,or any special procedures for installing it? HELP ME..
You might want to post this in the Oracle 10g XE support forum, where you might get a better response. The is is the support form for Oracle App Express..
Thank you,
Tony Miller
Monroe, WA -
How to delete with one click in ios7, How to delete with one click in ios7
In ios 7 how to delete a text message/mail with one swipe?
Also when u double click the home button how ro close open apps??
ThanksFor mail and message you swipe from right to left to delete.
For apps, when you double tap the home button, you swipe up and the app screenshot, to close out the app. -
Is there a way to move this file back to my downloads list?
Make use of Download Managers of Firefox and Softwraes
Addons File Manager
*https://addons.mozilla.org/en-US/firefox/addon/downthemall
*https://addons.mozilla.org/en-US/firefox/addon/flashgot/
External Softwares like
*IDM
Maybe you are looking for
-
I had pages on my ipad but I can't locate it to put on my ipad mini
I downloaded Pages on my ipad. I recently bought an ipad mini but I can't find my pages app to download on my ipad mini and I don't want to purchase it again. What can I do?
-
Error on .bash_profile _ oracle 11g preparing to install
Dears, I am preparing to install grid oracle 11g , In the envirment varaible on the oracle user on the .bash_profile I got the below error, please help me to solve it : ERROR: ./.bash_profile ': not a valid identifier export: `TMPDIR : command not fo
-
SMS through SAP ABAP in ECC 6.0
hi i want to send the SMS through SAP ABAP,for that I need any FM or any other thing. currenlty user send SMS through the TCODE SO01,but i want to do it through abap code. please tell me is there any FM exits in SAP to do this,or any other code i hav
-
I tried to install the latest version of Adobe Flash Player but got a message saying "not sufficient access privileges". Tried repairing permissions but this did not help. Searched computer for existing version of Adobe Flash Player that is supposed
-
Change binding of field at runtime
Hello experts, I have inserted a decimal field without default binding in my adobe form. Now I try to implement a dynamic binding of this field. So I inserted javascipt code in "initialize" of this field as follows: this.bind.match="dataRef"; this.bi