Using Oracle XQuery from Java Only
Hi,
I am interested to use the Oracle XQuery implementation to run on XML files only - no databases! Is it possible to do? Which jar file I need in JDeveloper to do that?
Does it support the latest XQuery version?
Our usecase is this :
1. There would be some BPEL template files in XML with some placeholders for runtime parameters and XQuery FLWR expressions.
2. At runtime, from Java, we would like to substitute those placeholders by runtime parameter values - would like to use the XQuery Java APIs to do that - see something similar available in Saxon XQuery parser.
Is it possible from Java using Oracle technology?
Thanks
Similar Messages
-
Problem calling oracle SP from Java
Hi I am trying to call an oracle SP from Java program and getting the error code 17060. Below is my code:
Oracle SP:
create or replace type item as object (itemnumber varchar2(9),itemdesc varchar2(35));
create or replace type uom as object (prodUOM varchar2(18), ratioDen NUMBER(1));
CREATE OR REPLACE TYPE uom_Arr aS VARRAY(100) OF uom;
create or replace package test_pkg_xml is
procedure test_sp_xml (item_rec item,
uom_tbl uom_arr);
end test_pkg_xml;
create or replace package body test_pkg_xml is
procedure test_sp_xml (item_rec item,
uom_tbl uom_arr)
is
begin
null;
end;
end test_pkg_xml;
Java Code
public class item implements SQLData {
private String sql_type;
public String itemnumber ;
public String itemdesc ;
public String getSQLTypeName() throws SQLException { return sql_type; }
public void readSQL(SQLInput stream, String typeName)throws SQLException
sql_type = typeName;
itemnumber = stream.readString();
itemdesc = stream.readString();
public void writeSQL(SQLOutput stream) throws SQLException
System.out.println("in write sql");
stream.writeString (itemnumber);
stream.writeString (itemdesc);
package com.tgt.dstb.dwm.dstbtowm.dao;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import java.sql.Connection;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Types;
import java.sql.SQLException;
import java.util.Map;
import java.util.Hashtable;
public class TestDOM
public static void test(Connection conn) throws Exception
item obj1 = new item();
Obj2 obj2 = new Obj2();
Obj2[] obj3 = {new Obj2(), new Obj2()};
String sql = "call " + "test_pkg_xml.test_sp_xml(?,?)";
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = factory.newDocumentBuilder();
Document document = parser.parse( "item.xml" );
Element itemMaster = document.getDocumentElement();
NodeList itemNumber = itemMaster.getElementsByTagName("itemNumber");
NodeList itemDesc = itemMaster.getElementsByTagName("itemDesc");
System.out.println("Item = ");
String itmname = DOMUtil.getSimpleElementText( itemMaster, "itemNumber" );
String itmdesc = DOMUtil.getSimpleElementText( itemMaster, "itemDesc" );
obj1.itemnumber = itmname;
obj1.itemdesc = itmdesc;
System.out.println("itmname = " + obj1.itemnumber );
System.out.println("itmdesc = " + obj1.itemdesc );
NodeList uoms = itemMaster.getElementsByTagName("uoms");
NodeList uom = itemMaster.getElementsByTagName("uom");
System.out.println("uom = ");
for( int i=0; i<uom.getLength(); i++ ) {
String itmprodUOM = DOMUtil.getSimpleElementText(
(Element)uom.item(i),"prodUOM" );
obj3.prodUOM = itmprodUOM;
String itmratioDen = DOMUtil.getSimpleElementText(
(Element)uom.item(i), "ratioDen" );
obj3[i].ratioDen = itmratioDen;
System.out.println( " "+ itmprodUOM +" ("+itmratioDen+")" );
try
Hashtable map = new Hashtable();
map.put ("item", Class.forName ("com.tgt.dstb.dwm.dstbtowm.dao.item"));
conn.setTypeMap(map);
System.out.println("here 11111 ");
CallableStatement stmt = conn.prepareCall("call test_pkg_xml.test_sp_xml(?,?)");
System.out.println("here 2 ");
stmt.setObject(1,obj1);
System.out.println("here 3 ");
stmt.setObject(2,obj3);
System.out.println("here 4 ");
stmt.execute();
System.out.println("here 5 ");
}catch (SQLException e)
System.out.println("exception :"+e.getErrorCode());
Can you please point out where I might be going wrong with the code? Any help would be greatly appreciated.
PS : I am getting the error 17060 after the stmt : System.out.println("here 2 ");
Thanks,
NitinAvi, I changed my code to:
package com.tgt.dstb.dwm.dstbtowm.dao;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import java.sql.Connection;
//import java.sql.CallableStatement;
import java.sql.*;
//import java.util.Map;
//import java.util.Hashtable;
import oracle.sql.ArrayDescriptor;
import oracle.sql.*;
import oracle.jdbc.*;
public class TestDOM
public static void test(Connection conn) throws Exception
item obj1 = new item();
Obj2 obj2 = new Obj2();
Obj2[] obj3 = {new Obj2(), new Obj2()};
String sql = " call test_pkg_xml.test_sp_xml(?,?)";
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = factory.newDocumentBuilder();
Document document = parser.parse( "item.xml" );
Element itemMaster = document.getDocumentElement();
NodeList itemNumber = itemMaster.getElementsByTagName("itemNumber");
NodeList itemDesc = itemMaster.getElementsByTagName("itemDesc");
System.out.println("Item = ");
String itmname = DOMUtil.getSimpleElementText( itemMaster, "itemNumber" );
String itmdesc = DOMUtil.getSimpleElementText( itemMaster, "itemDesc" );
obj1.itemnumber = itmname;
obj1.itemdesc = itmdesc;
System.out.println("itmname = " + obj1.itemnumber );
System.out.println("itmdesc = " + obj1.itemdesc );
NodeList uoms = itemMaster.getElementsByTagName("uoms");
NodeList uom = itemMaster.getElementsByTagName("uom");
System.out.println("uom = ");
for( int i=0; i<uom.getLength(); i++ ) {
String itmprodUOM = DOMUtil.getSimpleElementText(
(Element)uom.item(i),"prodUOM" );
obj3.prodUOM = itmprodUOM;
String itmratioDen = DOMUtil.getSimpleElementText(
(Element)uom.item(i), "ratioDen" );
obj3[i].ratioDen = Integer.parseInt(itmratioDen);
System.out.println( " "+ itmprodUOM +" ("+itmratioDen+")" );
try
System.out.println("here 1 ");
OracleCallableStatement stmt = (OracleCallableStatement)
conn.prepareCall("BEGIN test_pkg_xml.test_sp_xml(?,?); END;");
System.out.println("here 1.1 ");
System.out.println("here 1.2 ");
ArrayDescriptor desc1 = ArrayDescriptor.createDescriptor("UOM_ARR", conn);
ARRAY array_to_pass1 = new ARRAY(desc1, conn, obj3);
System.out.println("here 2 ");
stmt.setObject(1,obj1,OracleTypes.STRUCT);
System.out.println("here 3 ");
stmt.setArray(2,array_to_pass1);
System.out.println("here 4 ");
stmt.execute();
System.out.println("here 5 ");
}catch (Exception e)
e.printStackTrace();
However, now I the code is printing
"here 1 "
and then giving
"[1/4/07 11:37:28:133 CST] 00000036 SystemErr R java.lang.ClassCastException: com.ibm.ws.rsadapter.jdbc.WSJdbcCallableStatement"
at "OracleCallableStatement stmt = (OracleCallableStatement)
conn.prepareCall("BEGIN test_pkg_xml.test_sp_xml(?,?); END;");"
statement.
I am using Rational App Developer Version 6.0.1 and getting a connection using
the below code:
DataSource dataSource=null ;
Context jndiContext = new InitialContext();
dataSource =
(DataSource)jndiContext.lookup("java:comp/env/jdbc/DWM3DDS");
Connection wsConn = dataSource.getConnection();
Looks like this exception occurs when I am casting java.sql.Connection object to OracleCallableStatement. Do you have any idea why this might be occuring? Have you encountered this kind of a problem?
Thanks,
Nitin -
Using word/excel from java (client or weblogic server)
Hi everybody,
i want to use excel / word functionality from java in two different variants:
-> serverside
-> clientside
I tried the weblogic.comc and i got serveral classes but in the remote-package i got only a utitlity-class.
My knowlege about COM is rather bad.
Does anybody did this bevor and
-> can say me, if it is correct, that i only got a utility-class (so how will i use it from the client ?!)
-> has a example for using Excel / Word from Java in bea weblogic
-> has a example for using Excel / Word directly in a client (not via rmi)
Thanks
Ciao
SvenSven, This is a really bad idea. Why don't you tell me
what your trying to do and I wil surely give you a better alternative
JRadecki
"Sven Roesner" <[email protected]> wrote:
>
Hi everybody,
i want to use excel / word functionality from java in two different variants:
-> serverside
-> clientside
I tried the weblogic.comc and i got serveral classes but in the remote-package i got only a utitlity-class.
My knowlege about COM is rather bad.
Does anybody did this bevor and
-> can say me, if it is correct, that i only got a utility-class (so how will i use it from the client ?!)
-> has a example for using Excel / Word from Java in bea weblogic
-> has a example for using Excel / Word directly in a client (not via rmi)
Thanks
Ciao
Sven -
Using Oracle Berkeley DB Java Edition RELEASE 3.2
Hi,
I am completely new to Oracle. I intend to use Oracle Berkeley DB Java Edition RELEASE 3.2., in conjunction with Java.
Can some one help me figure out what documentation I should use, and the learning path ?
Any suggestions would be greatly appreciated.
Thanks
Ravi Banthia
KolkataPlease refer
http://www.oracle.com/technology/products/berkeley-db/je/index.html -
Hi all!, someone knows about an API that let me use a scanner from Java?
without programing JNI code.
thks in advance!.The Java Twain package from http://www.gnome.sk does exactly what you need. You do not have to bother about jni, you can get an image from the scanner directly from your java application.
Erika -
Patches 7446163 y 6851110 in order to use Oracle Text from UCM
Hello, we have Oracle Enterprise Edition 11.2.0.1 on AIX 6.1.0.0 (64 bits). The client want to use Oracle Text from Universal Content Management, he told me about install the patches 7446163 y 6851110 in order to enable Oracle Text from UCM. I reviewed in Metalink but the readme said that those patches are for Oracle 11.1.0.7. That version (11.2.0.1) include already those patches or those are necessary for we can use the funcionality of Oracle Text from Universal Content Management? I reviewed the components installed on database and the Oracle Text is installed and active.
Thanks for your help.
Sincerely,
Ruben Nieto
DBAHi
Oracle DB usually would be installed with Oracle Text enabled (the db side) . To use the features for this we need to have OracleText component enabled on UCM which as you mentioned is already installed and enabled on the ucm server .
If both the above conditions are already met then you would not need to install any further patches.
Let me know if it is fine on db and ucm .
Verify that Oracle Text is enabled on db by executing the following query :
select comp_name, status from dba_registry;
It should return the the following result : Oracle Text VALID
To verify if the component for UCM is installed then you would need to check Administration - Configuration for <instance name> - Enabled Components
Thanks
Srinath
Edited by: Srinath Menon on Dec 26, 2010 8:38 PM -
Passing SQL-Parameters to Oracle-Reports from java
hello,
i want to write an application in the following way:
on a java-frontend an user can select values for different
parameters. these values should be to transferred to the sql-
query of the reports rdf file. what is the syntax of an
parameter passed from java to oracle reports.
does this work with runtime.exec()... ?
does anybody have an example.
any help would be very appreciated.
greetings
Thorsten LorenzIn order to pass the parameters to report rdf, you can create user parameters in the oracle report builder, hook up the parameters with query. For example, you can create user parameter P_DEPTNO, then create a sql query: select * from dept where deptno = :P_DEPTNO. When you run this report, you give P_DEPTNO=10 as parameter, the rdf will generate report that only prints out department 10's information.
Once you have this kind of report created, you have several ways to achieve what you want.
1. use rwrun60. In your java program, you can invoke rwrun60 via runtime.exec(cmd) where cmd = rwrun60 report=dept.rdf userid=scott/tiger@orcl destype=file desformat=pdf desname=dept.pdf p_deptno=<value_from_java_app>
2. similarly, use rwcli60. the cmd would be:
cmd = rwcli60 server=repserver report=dept.rdf userid=scott/tiger@orcl destype=file desformat=pdf desname=dept.pdf p_deptno=<value_from_java_app>
3. use rwcgi60. Instead of using runtime.exec, you should use java URL object to run the report in the web environment.
option 2 & 3 takes advantage of powerful functionality of reports server, and it is much more scale than option 1. -
Requirement to be fulfilled using PI 7.3 Java only installation
Hi Experts,
We have a requirement depicted as below and need to confirm if the same is possible in PI 7.3 JAVA only
installation where there is no possibility of using ccBPM.
Step 1. System A sends web service request to PI,
Step 2. PI sends the request to System B which is a web service call
Step 3. System B sends response back to PI
Step 4. PI gets the response from System B, this response needs to transformed and mapped and sent to System C web service request.
Step 5. The response from System C needs to be sent back to System A which initiated the call.
Please give a thought based on your experience and expertise if this is possible; given the limitation of java only installation which is without ccBPM.
- ShripadHi Shripad,
For modeling with BPMN, refer the below guide:
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/c052052e-fbab-2b10-0d9a-9feed5463589
SOap look up in mapping from System B response to System A should solve your issue.
--Divyesh -
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 -
On making call to Oracle procedures from Java, Value becomes null on oracle
We are using some user defined Oracle data types in my Java/J2EE application
and some of them are Oracle collections(ex. VARRAY).
We are making a call to Procedures/Functions from Java, there are some
parameters of user defined data types declared in the
procedures/functions, from java the values are properly setting to these
user defined data type parameters and sending to Procedures.
We are not getting any exception at Java side and Oracle side and values
are becoming blank/null at oracle procedure side for the parameters of
user defined data types.
But when do the count of collection of user defined data type then it is
properly giving the size of collection(VARRAY).
When we are trying to read the values from the collection(VARRAY) it is
giving blank/null value and there is no exception.
Please let me know if you have any suggestion on this?user7671994 wrote:
When we are trying to read the values from the collection(VARRAY) it is
giving blank/null value and there is no exception.If you are talking about VARCHAR2 parameters of the objects - then you should add orai18n.jar to classpath. -
Using Oracle Wallet for Java connection
Hi,
Can anyone tell me how to acces the Oracle wallet from my Java application without using the thin or oci drivers?No answer was found for this, we ended up using an OCI driver for the connection to the wallet. Code (in java) was as follows for reference:#
private static Connection walletconn() throws Exception{
String url = "jdbc:oracle:oci:/@DATABASE";
OracleDataSource ods = new OracleDataSource();
ods.setURL(url);
Connection conn = ods.getConnection();
return connl; -
Call a C++ services using an uuid from java
I need to call a C++ services which is using the UUID for RPC. The interface is having the UUID. The previous client program is also in C++, they have used RpcBindingFromStringBinding(UUID value, .,.,.) to call the interface. Right now I need to call this service from Java using the UUID. Can anyone help me in it.
Passing the UUID should be the easy part, the tricky bit is performing an RPC from Java to C++. How are you doing that? Once you sort that out, passing arguments should be straight forward.
Note: Java's RMI only works between a client server running RMI. To connect to C++ server, you need to use a Java client library which is compatible with your C++ server.
If you still don't know how to perform the RPC call, I suggest you contact the people supporting the C++ program as they should know how RPC calls are made currently. If they don't know, it is highly unlikely we can guess a solution unless you are willing to change the C++ server to use a known RPC mechanism. -
Using Inbound IDOC from Java system creation of Outbound delivery
Dear Experts,
The scenario we are having is really very interesting. Hopefully its a good learning for me and also for others also.
The scenario is,
After sales order creation the details will be sent to one Non SAP system (Java) for performing some tasks related to forwarding agent decision, shipping date and etc. Once the details are finalized in that Java system then, the details needs to be transferred to SAP as "Inbound IDOC" process. For this proposed to use the SAP Jco middle ware.
Once the details transfered from Java system to SAP then, the outbound IDOC needs to get generated automatically. Assuming the stock for that sales order line item is available. Also one more complexity is, our client is using custom transaction (ZVl10C) for delivery creation.
Now Query is,
1. Which IDOC, message type and Functional module needs to be used for creating the delivery automatically..??
2. As per assumption, stock of that sales order line item should be available. Due to some business reason the stock was removed during inbound IDOC transfer then, what will happen to the IDOC..?. How to avoid this situation..??
3. As we told we are re going to use SAP Jco b/w SAP & Java system. In this case, how the data will get transfered from Java system to SAP..?
Thanks in advance for the replies I am going to get
Regards,
VELThanks for the feedback. This question is resolved
-
Using ExecutorService class from java.util.concurrent package
Dear java programmers,
I have a question regarding the ExecutorService class from java.util.concurrent package.
I want to parse hundreds of files and for this purpose I'm implementing a thread pool. The way I use the ExecutorService class is summarized below:
ExecutorService executor = Executors.newFixedThreadPool(10);
for (int i = 0; i < 1000; i++){
System.out.println("Parsing file No "+i);
executor.submit(new Dock(i));
executor.shutdown();
try {
executor.awaitTermination(30, TimeUnit.SECONDS);
} catch (InterruptedException ex) {
ex.printStackTrace();
executor.shutdownNow();However, the code snippet above creates all the 1000 threads (Dock objects) at once and loads them to the executor, and thus I'm worrying about memory leak. I haven't tested it on 1000 files yet but just on 50 small ones, and even if the program prints out "Parsing file No "+i 50 times at once, it executes normally the threads in the background.
I guess the write way would be to keep the number of active/idle threads in the executor constant (lets say 20 if the thread pool's size is 10) and submit a new one whenever a thread has been finished or terminated. But for this to happen the program should be notified someway whenever a thread is done. Can anybody help me do that?
thanks in advance,
TomOk I found a feasible solution myself although I'm not sure if this is the optimum.
Here's what I did:
ExecutorService executor = Executors.newFixedThreadPool(10);
Future<String> future0, future1, future2, future3, future4, future5, future6, future7, future8, future9;
Future[] futureArray = {future0 = null, future1 = null, future2 = null, future3 = null, future4 = null, future5 = null,
future6 = null, future7 = null, future8 = null, future9 = null};
for (int i = 0; i < 10; i++){
futureArray[i] = executor.submit(new Dock(i));
}I created the ExecutorService object which encapsulates the thread pool and then created 10 Future objects (java.util.concurrent.Future) and added them into an Array.
For java.util.concurrent.Future and Callable Interface usage refer to:
[http://www.swingwiki.org/best:use_worker_thread_for_long_operations]
[http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Java/Chapter10/concurrencyTools.html]
I used a Future[] Array to make the code neater. So after that I submitted -and in this way filled up- the first 10 threads to the thread pool.
int i = 9;
while (i < 1000){
for (int j = 0; j < 10; j++){
if (futureArray[j].isDone() && i < 999){
try{
i++;
futureArray[j] = executor.submit(new Dock(i));
} catch (ExecutionException ex) {
ex.printStackTrace();
} catch (InterruptedException ex) {
ex.printStackTrace();
try {
Thread.sleep(100); // wait a while
} catch(InterruptedException iex) { /* ignore */ }
executor.shutdown();
try {
executor.awaitTermination(60, TimeUnit.SECONDS);
} catch (InterruptedException ex) {
ex.printStackTrace();
executor.shutdownNow();
}Each of the future[0-9] objects represents a thread in the thread pool. So essentially I'm check which of these 10 threads has been finished (using the java.util.concurrent.Future.isDone() method) and if yes I replenish that empty future[0-9] object with a new one. -
Passing pl/sql variable to oracle procedure from java
Dear
Sir/madam
From java its easy to call procedure or function to get pl/sql variables like cursor type or varray type and cast back to that equi type thro' oracle extn package.Is there any way it could be done vice versa.Can i pass Oarcles Pl/SQL datatype like collection Of type Varray/Custom Object or Cursor,Array type to a procedure or function from java program.Is it possible to pass like that.If so could you kindly give a samll eaxample or URL where same type of example could be found
regards
kingshukDear
Sir/madam
From java its easy to call procedure or function to get pl/sql variables like cursor type or varray type and cast back to that equi type thro' oracle extn package.Is there any way it could be done vice versa.Can i pass Oarcles Pl/SQL datatype like collection Of type Varray/Custom Object or Cursor,Array type to a procedure or function from java program.Is it possible to pass like that.If so could you kindly give a samll eaxample or URL where same type of example could be found
regards
kingshu i suggest to read JPublisher doc - it help support or convert PL/SQL types in Java
http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96658.pdf
Kuassi
Maybe you are looking for
-
How to partition already partitioned hard drive on Macbook pro 10.9.4
Hello I have a macbook pro. I partitioned the hard drive before and installed windows 7. Now the hard disk size of windows is getting full. So I need to shrink the windows part. I tried to partition it again but bootcamp disappears. I have deleted th
-
JV variant report error - Unable to determine joint venture details
Hi Guys, We are testing some of our FX variants and are running into a few JV errors that are preventing us from completing the BDC test session. The transaction which we used is customized one ZFICFX and variants involved are REAL FX. While running
-
can anyone help me with my new phone? i got a text message with a song in it i really want but don't know how to save it to my phone???
-
Find out which style is not being used
Hi, I am viewing my long forgotten css code, i find that the code probably redundant, I like to know how to find out if any element or any pages/file in the project is using that particular style or not? So i can completely delete it
-
Indesign cs5.5 startet nicht mehr-
-unter Windows 7 pro. Wir haben schon den Cache gelöscht, Indesign neu installiert und die Systemwiederherstellung benutzt. Cache löschen brachte nichts und die anderen beiden Maßnahmen hatten ihren Effekt nach einem weiteren Systemneustart verloren