XmlParse and XmlValidate
I am getting an error thrown at me and I am not for sure why.
I am using a cfc to send back XML code for the information required
in a query. I have a dtd file that has been given to me by the
company that is wanting this portal set up for them (checking
availability for parts). Being a good little coder I decided to go
ahead a validate against this dtd file in a test environment. the
string cfoutput looks correct. but when I do a cfdump of the
cfhttp.FileConnet I get a wddx top level element. and then when I
validate, i get errors thrown back at me. Can anyone help me with
why this is happening?
Email
set the return type of the function in the cfc to "XML"
You might also want to use <cfheader name="content-type"
value="text/xml">
Similar Messages
-
JTextPane and XMLParser and jdk .-) problems
Hi there.
I have a nice problem, which really gives me headaches.
I have an XML editor (working as an applet or as an aplication, using a JTextPane). All worked ok untill jdk1.3 and parts even until jdk1.4. Now 2 big problems appeared.
1.Under jdk1.4.1:
Spaces between lines are awful big. The actual characters are ok, but the cursor is almost twice as the characters. The distance from the bottom of a character and the bottom of the line is pretty big. Now that looked to me as a SpaceBelow or LineSpacing problem. I've tried to set up the SpaceBelow or/and LineSpacing... everything that I've thought it should work. No result. Seems like they have no effect when XMLParser comes in place and sets up the document content (at least i think this is the reason, also i'm not sure). An element tree implemented shows me that this attributes are set to the values I've intended, but no 'visual' effect. Does anyone know ANYTHING about this? Please!
2.Starting from jdk1.3. Doubling of tags.
If the XML editor reads something like <FT>something</FT> from a xml file, it sets in the JTextPane <FT><FT>something</FT></FT>. It's working under jdk1.2 but if I switch to 1.3 or 1.4does something like this. Any idea what's going on? Could it be an unfortunate mix between jdk and xalan libraries?
I REALLY hope that ANYONE of you knows ANYTHING about these!!!
THNX!Hi DrClap.
Well, this would be the best thing to do. The only problem is that those are long time gone. Not really 'gone', but they are not to be found.
There's something about first problem: At the end of starting process, after the parser finished his work, if I come and set the attributes (in the document of the JTextPane, using StyleConstants) with replace set to true, the display is ok but, of course, I loose any style defined in the xml file. That means is not a problem of the JTextPane in jdk 1.4 (at one time I thought it might be a 'mapping' problem of the JTP in 1.4) or?
Because I'm really stuck, I have all kind of strange ideas!!!
Could be "old libraries(for the parser) - new jdk" mixture problem, perhaps? (I've told you!)
THX for your previous response. -
XMLParser and Special Characters
Hi,
I'm trying to read in an XML Document from a stream (e.g. a file) using XMLParser. The document contains german text (i.e. lots of special characters like umlauts �, �, � and others).
If I read this stream into a text string all these special characters are perfectly handled (i.e. � looks like an �, etc.).
However, if I import the stream into an XMLParser.Document using ImportDocument the umlauts seem to be scrambled. If the imported document is without any changes exported again to a stream (using ExportDocument) the umlauts are not displayed correctly anymore.
Example Stream:
<?xml version="1.0" encoding="iso-8859-1" ?>
<UserID>M�ller</UserID>
If this stream is imported into an XMLParser.Document and then exported again it contains
<UserID>M��ller</UserID>
I'm using correct XML encoding iso-8859-1 which is for western european languages and I guess it should not be a Forte locale issue since simple string handling of the stream works fine.
Thanks for any hints,
DanielLet's start at the basics. Right now you are quite limited by your database character set as US7ASCII. You need to migrate to something that will support Latin and Greek characters at least. Maybe EL8ISO8859P7, or UTF-8. Please look at documentation Scanner Utility, available for Oracle 8.1.6 and above to make sure migration is safe before doing any import/export. The title of paper is: Database Character Set Migration, at: http://technet.oracle.com/products/oracle8i/listing.htm#nls
UTF-8 will give you more versatility in the languages that your customer supports now or in the future. There is some performance overhead using Unicode but how much depends? I would base a large part of the Unicode decision on how likely it would be that other languages would need to be supported in the future and special character support.
The special characters that your customer would like to support may already exist in Unicode. IF they don't or you choose another character set then your customer will need to look at the National Language Support Guide, Appendix 'B' "Customizing Locale Data"
Are you running Greek windows? Otherwise how will you enter Greek characters? If you are using Greek windows you probably need to set your client NLS_LANG to EL8MSWIN1253.
On your Forms questions you might want to take a look at the following :
1. Chapter 4 of "Oracle Forms Developer and Reports Developer Release 6i: Guidelines for Building
Applications" discusses How to design MultiLingual Applications.
http://otn.oracle.com/docs/products/forms/doc_index.htm -
Why do the XMLParser replace '<' with '<' in a CDATA-Element?
I have a Stylesheet with an Element like this:
<script lang...><![CDATA[
function test(){
for(i=0; i<2; i++)...
}]]>
</script>
Now I use the oracle.xml.parser.v2.XMLParser to parse the Stylesheet in this way:
parser = new DOMParser();
parser.setPreserveWhitespace(true);
parser.parse(xslURL);
xsldoc = parser.getDocument();
and now I print it out this way:
xsldoc.print(out);
This is the result:
... for(i=0; i<2; i++) ...
How can I tell him not to do this replacement? I thought all characters inside the <![CDATA[-tag wouldn't be parsed. Am I wrong?
I use the XMLParser 9.0.1.0.0 ProductionI've found a workaround with <xsl:comment> like this:
<script ...>
<xsl:comment>
<![CDATA[
...Javascriptcode...
]]>
</xsl:comment>
</script>
null -
What are the differences/advatanges of using the XMLParser in the javabeans package as opposed to using JAXB to create your own javabean object. It seems like it would be much easier to just create the javabean yourself and then when you need to save it to xml, you just send it to XMLParser. No need to recreate classes after you change attributes of your data object, no complicated marshalling procedures. Just give the XMLParser object the JavaBean object and your finished. What are the benefits of using JAXB?
I don't see an XMLParser class in the java.beans package so I'll assume you are referring to the XMLEncoder and XMLDecoder classes.
From what I can tell, you need to define a concrete class definition for your bean. This automatically creates an XML file format.
JAXB on the other hand takes an XML defnintion and creates java source matching the schema.
Lets say you need to interface with company X. They don't use Java. They give you an XML file format that they support. Even if you can define Java beans to match their format, you have no flexibility as to how you can define your classes.
JAXB on the other hand, allows you to take their schema, and translate it into Java classes. You can also customize the binding to match an existing code base.
The other main advantage is that it is much harder to write java classes than to write a schema. Once you throw in validation, generating code from a schema starts looking very good. -
Oracle 9i and xmltype, ora-03001
I get this message: 'ora-03001 unimplemented feature' when i
trying to create a table with this statement: create table
purchaseorder(podocument sys.xmltype);
-The user has the following roles:
connect, resource, javauserpriv, query rewrite, create any
directory.
-And execute privilege on xmlparser and xmldom (granted by sys).
-The init.ora file is included with query_rewrite_enabled=true,
query_rewrite_integrity=trusted.
What's wrong?Colleague, I had problem the same that its, also with the postagem of a message here in this forum. I have the successfully installed Oracle 9i EE, after two weeks of very work, in IBM to xServer 220, with SuSE 7.2 This error occurred due to the fact of incorrect parameters of the init.ora, as well as, through some definite parameters incorrectly, in that if it says respect the 0 variable of environment of the ORACLE. One remembers to modify parameter REMOTE_LOGIN... of EXCLUSIVE for NONE and of preference it comments this in its archive INIT.ORA. Of one looked at in check list of installation of the Oracle, as well as in the specific manual of pattern for its distribution for the correct definition of the parameters of its archive of pattern.
-
I'm having a problem with xmlParse and CF11. I have a site running perfectly under either CF9 or CF10. It uses xml files for various site settings and static content. Under CF11 I'm receiving the following:
An error occurred while Parsing an XML document. Invalid byte 2 of 2-byte UTF-8 sequence.
I've sent the document through various xml validators, no issues. Like I said, the exact same document parsed fine under CF9 & CF10 -- in fact it was created by CF9 and/or CF10.
Any ideas on what might be causing this (other than a CF11 bug) and a possible work around. (it's hard to create a work around when I'm not even sure the issue)
BTW, I downloaded and installed the latest CF11 yesterday. A check for updates does not show any available.Hmmm, I found the issue. I found a post on another forum that suggested opening the xml document in Firefox as it's xml parser is very sensitive (as is CF11 apparently). It pointed right to the offending text -- a high byte character (actually a few). It still baffles me that CF9 & 10 created these XML documents and parsed them without issue all this time.
-
Performance problem, statspack report included.
HI,
on my 9.2.0.8 cpu_count=12 EE I've got job which takes 5h , there is strange top sql reported:
STATSPACK report for
DB Name DB Id Instance Inst Num Release Cluster Host
E1 2020101010 E1 1 9.2.0.8.0 NO test1
Snap Id Snap Time Sessions Curs/Sess Comment
Begin Snap: 56073 22-Mar-10 15:00:04 35 5.7
End Snap: 56078 22-Mar-10 20:00:04 38 5.6
Elapsed: 300.00 (mins)
Cache Sizes (end)
~~~~~~~~~~~~~~~~~
Buffer Cache: 1,024M Std Block Size: 8K
Shared Pool Size: 320M Log Buffer: 2,000K
Load Profile
~~~~~~~~~~~~ Per Second Per Transaction
Redo size: 141,422.83 23,063.29
Logical reads: 21,928.15 3,576.05
Block changes: 695.89 113.49
Physical reads: 424.41 69.21
Physical writes: 36.35 5.93
User calls: 21.19 3.46
Parses: 115.96 18.91
Hard parses: 1.41 0.23
Sorts: 28.80 4.70
Logons: 0.14 0.02
Executes: 5,099.90 831.69
Transactions: 6.13
% Blocks changed per Read: 3.17 Recursive Call %: 99.86
Rollback per transaction %: 0.00 Rows per Sort: 3.88
Instance Efficiency Percentages (Target 100%)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Buffer Nowait %: 100.00 Redo NoWait %: 100.00
Buffer Hit %: 98.07 In-memory Sort %: 100.00
Library Hit %: 99.43 Soft Parse %: 98.78
Execute to Parse %: 97.73 Latch Hit %: 100.00
Parse CPU to Parse Elapsd %: 39.63 % Non-Parse CPU: 99.50
Shared Pool Statistics Begin End
Memory Usage %: 19.64 94.21
% SQL with executions>1: 73.59 14.19
% Memory for SQL w/exec>1: 63.89 9.21
Top 5 Timed Events
~~~~~~~~~~~~~~~~~~ % Total
Event Waits Time (s) Ela Time
CPU time 10,436 78.98
db file sequential read 231,010 1,484 11.23
db file scattered read 333,736 733 5.55
log file sync 67,760 206 1.56
db file parallel write 63,946 204 1.54
^LWait Events for DB: E1 Instance: E1 Snaps: 56073 -56078
-> s - second
-> cs - centisecond - 100th of a second
-> ms - millisecond - 1000th of a second
-> us - microsecond - 1000000th of a second
-> ordered by wait time desc, waits desc (idle events last)
Avg
Total Wait wait Waits
Event Waits Timeouts Time (s) (ms) /txn
db file sequential read 231,010 0 1,484 6 2.1
db file scattered read 333,736 0 733 2 3.0
log file sync 67,760 0 206 3 0.6
db file parallel write 63,946 0 204 3 0.6
direct path write (lob) 45,642 0 82 2 0.4
control file parallel write 7,000 0 28 4 0.1
log file parallel write 205,617 0 14 0 1.9
process startup 450 0 11 25 0.0
control file sequential read 8,068 0 8 1 0.1
log file switch completion 104 0 3 28 0.0
log buffer space 86 0 2 22 0.0
SQL*Net break/reset to clien 3,632 0 1 0 0.0
latch free 1,241 23 1 0 0.0
direct path read 3,432 0 1 0 0.0
log file single write 160 0 0 3 0.0
direct path write 2,074 0 0 0 0.0
log file sequential read 160 0 0 2 0.0
direct path read (lob) 76 0 0 3 0.0
SQL*Net message from dblink 38 0 0 4 0.0
buffer busy waits 19 0 0 4 0.0
single-task message 1 0 0 64 0.0
SQL*Net more data to client 2,493 0 0 0 0.0
LGWR wait for redo copy 369 0 0 0 0.0
library cache pin 3 0 0 0 0.0
enqueue 7 0 0 0 0.0
SQL*Net message to dblink 38 0 0 0 0.0
SQL*Net message from client 240,510 0 378,158 1572 2.2
jobq slave wait 9,559 9,475 27,883 2917 0.1
wakeup time manager 583 583 16,960 29090 0.0
SQL*Net message to client 240,514 0 0 0 2.2
SQL*Net more data from clien 2,990 0 0 0 0.0
^LBackground Wait Events for DB: E1 Instance: E1 Snaps: 56073 -56078
-> ordered by wait time desc, waits desc (idle events last)
Avg
Total Wait wait Waits
Event Waits Timeouts Time (s) (ms) /txn
db file parallel write 63,946 0 204 3 0.6
control file parallel write 7,000 0 28 4 0.1
log file parallel write 205,617 0 14 0 1.9
control file sequential read 3,998 0 4 1 0.0
db file scattered read 237 0 1 5 0.0
db file sequential read 161 0 1 3 0.0
log file single write 160 0 0 3 0.0
direct path read 3,398 0 0 0 0.0
direct path write 2,070 0 0 0 0.0
log file sequential read 160 0 0 2 0.0
rdbms ipc reply 259 0 0 1 0.0
log buffer space 11 0 0 11 0.0
LGWR wait for redo copy 369 0 0 0 0.0
latch free 34 2 0 1 0.0
buffer busy waits 1 0 0 0 0.0
rdbms ipc message 590,267 22,981 82,922 140 5.3
pmon timer 6,288 6,288 17,570 2794 0.1
smon timer 96 50 16,604 ###### 0.0
^LSQL ordered by Gets for DB: E1 Instance: E1 Snaps: 56073 -56078
-> End Buffer Gets Threshold: 10000
-> Note that resources reported for PL/SQL includes the resources used by
all SQL statements called within the PL/SQL code. As individual SQL
statements are also reported, it is possible and valid for the summed
total % to exceed 100
CPU Elapsd
Buffer Gets Executions Gets per Exec %Total Time (s) Time (s) Hash Value
385,750,162 1 385,750,162.0 97.7 ######## 15723.50 2420406373
Module: 01@ me2xml.sql
declare v_message VARCHAR2(2000); v_inserts VARC
HAR2(2000); v_voucher VARCHAR2(2000); v_vls
VARCHAR2(2000); v_posi VARCHAR2(2000); v_posih
VARCHAR2(2000); v_rep_inderts VARCHAR2(2000); begin upd
ate PARAM_SYSTEM set SYS_WARTOSC_TEKST = null where
351,634,942 87,908,729 4.0 89.1 1307.36 1617.33 4265647904
Module: 01@ posi2xml.sql
select longname from javasnm$ where short = :1
...other statements are way lowerAny ideas how can I optimize 'select longname from javasnm$ where short = :1' ?
Regards.
GregThank You , but I'm unable to reduce java calls ,because the whole code is doing xml transformations (xmlparse and xmldom).
My java pool is:
SQL> show parameters java
NAME TYPE VALUE
java_max_sessionspace_size integer 0
java_pool_size big integer 167772160
java_soft_sessionspace_limit integer 0
and my shared pool is:
SQL> show parameters shared
NAME TYPE VALUE
hi_shared_memory_address integer 0
max_shared_servers integer 20
shared_memory_address integer 0
shared_pool_reserved_size big integer 8388608
shared_pool_size big integer 335544320
shared_server_sessions integer 0
shared_servers integer 0
btw how do You know I'm using shared pool for ad-hoc queries ?
The 5h interval spans one procedure call , there is no other workload on database.
Regards.
Greg -
Backup/Recovery from web application
Hello guys,
I am using Oracle 9i as DB and Oracle 9iAS for web application server. I want to provide Backup and Recovery functionality to the user via web. I don't know any thing in this regard.
Is it possible that we can take backup and recovery from web application?
Is there any alternative for this function.
any other comments will be appreciated.
Thank you,
Jawed Nazar AliRead this article in order to get an idea about Java Stored Procedures.
Oracle Developer JAVA STORED PROCEDURES
Simplify with Java Stored Procedures
By Kuassi Mensah
Use Java stored procedures to bridge SQL, XML, Java, and J2EE and Web Services.
Stored procedures allow a clean separation of persistence logic that runs in the database tier from business logic that runs in the middle tier. This separation reduces overall application complexity and increases reuse, security, performance, and scalability.
A major obstacle, however, for widespread adoption of stored procedures is the set of various proprietary, database-dependent implementation languages that different database vendors use. The use of Java-based stored procedures fixes this concern. Oracle has implemented ANSI standards that specify the ability to invoke static Java methods from SQL as procedures or functions. This implementation is called simply "Java stored procedures."
In this article, you will learn how Java stored procedures help simplify and increase the performance of your business logic and extend database functionality. I'll show how Oracle enables the use of Java stored procedures within the database. I'll also look at how Java stored procedures access data, and show how to create a basic Java stored procedure.
PL/SQL or Java
When you think of Oracle stored procedures, you probably think of PL/SQL. Oracle, however, has provided Java support in the database since Oracle8i, to offer an open and portable alternative to PL/SQL for stored procedures. I can hear the $64,000 question: "How do I choose between PL/SQL and Java? Should I forget all the things I've been told about PL/SQL and move on to the greener Java pastures?"
Both languages are suitable for database programming, and each has its strengths and weaknesses. In deciding which language to use, here's a general rule of thumb:
Use PL/SQL for database-centric logic that requires seamless integration with SQL and therefore complete access to database objects, types, and features.
Use Java as an open alternative to PL/SQL for database independence, but also for integrating and bridging the worlds of SQL, XML, J2EE, and Web services.
OracleJVM Lets You Run Java within the Database
Since Oracle8i, Release 1 (Oracle 8.1.5), Oracle has offered a tightly integrated Java virtual machine (JVM) that supports Oracle's database session architecture. Any database session may activate a virtually dedicated JVM during the first Java code invocation; subsequent users then benefit from this already Java-enabled session. In reality, all sessions share the same JVM code and staticsonly private states are kept and garbage collected in an individual session space, to provide Java sessions the same session isolation and data integrity capabilities as SQL operations. There is no need for a separate Java-enabled process for data integrity. This session-based architecture provides a small memory footprint and gives OracleJVM the same linear SMP scalability as the Oracle database.
Creating Java Stored Procedures
There are a few steps involved in turning a Java method into a Java stored procedure. These include loading the Java class into the database using the loadjava utility, and publishing the Java methods using a call specification (Call Spec) to map Java methods, parameter types, and return types to their SQL counterparts. The following section shows how to do this.
I'll use a simple Hello class, with one method, Hello.world(), that returns the string "Hello world":
public class Hello
public static String world ()
return "Hello world";
The Loadjava Utility
Loadjava is a utility for loading Java source files, Java class files, and Java resource files; verifying bytecodes; and deploying Java classes and JAR files into the database. It is invoked either from the command line or through the loadjava() method contained within the DBMS_JAVA class. To load our Hello.class example, type:
loadjava -user scott/tiger Hello.class
As of Oracle9i Release 2, loadjava allows you to automatically publish Java classes as stored procedures by creating the corresponding Call Specs for methods contained in the processed classes. Oracle provides Oracle9i JDeveloper for developing, testing, debugging, and deploying Java stored procedures.
The Resolver Spec
The JDK-based JVM looks for and resolves class references within the directories listed in the CLASSPATH. Because Oracle database classes live in the database schema, the OracleJVM uses a database resolver to look for and resolve class references through the schemas listed in the Resolver Spec. Unlike the CLASSPATH, which applies to all classes, the Resolver Spec is applied on a per-class basis. The default resolver looks for classes first in the schema in which the class is loaded and then for classes with public synonyms.
loadjava -resolve <myclass>
You may need to specify different resolvers, and you can force resolution to occur when you use loadjava, to determine at deployment time any problems that may occur later at runtime.
loadjava -resolve -resolver "((* SCOTT) (foo/bar/* OTHERS)
(* PUBLIC))"
Call Spec and Stored Procedures Invocation
To invoke a Java method from SQL (as well as from PL/SQL and JDBC), you must first publish the public static method through a Call Spec, which defines for SQL the arguments the method takes and the SQL types it returns.
In our example, we'll use SQL*Plus to connect to the database and define a top-level Call Spec for Hello.world():
SQL> connect scott/tiger
SQL> create or replace function helloworld return
VARCHAR2 as language java name 'Hello.world () return
java.lang.String';
Function created.
You can then invoke the Java stored procedure as shown below:
SQL> variable myString varchar2[20];
SQL> call helloworld() into :myString;
Call completed.
SQL> print myString;
MYSTRING
Hello world
Java stored procedures are callable, through their Call Spec, from SQL DML statements (INSERT, UPDATE, DELETE, SELECT, CALL, EXPLAIN PLAN, LOCK TABLE, and MERGE), PL/SQL blocks, subprograms, and packages, as well as database triggers. The beauty of Call Spec is that stored procedure implementations can change over time from PL/SQL to Java or vice versa, transparently to the requesters.
Call Spec abstracts the call interface from the implementation language (PL/SQL or Java) and therefore enables sharing business logic between legacy applications and newer Java/J2EE-based applications. At times, however, when invoking a database-resident Java class from a Java client, you may not want to go through the PL/SQL wrapper. In a future release, Oracle plans to provide a mechanism that will allow developers to bypass the Call Spec.
Advanced Data-Access Control
Java stored procedures can be used to control and restrict access to Oracle data by allowing users to manipulate the data only through stored procedures that execute under their invoker's privileges while denying access to the table itself. For example, you can disable updates during certain hours or give managers the ability to query salary data but not update it, or log all access and notify a security service.
Sharing Data Logic Between Legacy and J2EE Applications
Because legacy applications and J2EE applications both invoke stored procedures through the Call Spec, the same data logic can be shared between J2EE and non-J2EE worlds. Thanks to Call Spec, this data logic can be shared regardless of the implementation language used (whether PL/SQL or Java).
Autogeneration of Primary Keys for BMP Entity Beans
When using BMP for EJB entity beans, a bean instance can be uniquely identified by the auto-generated primary key associated with the newly inserted data as a return value for ejbCreate(). You can retrieve this value within ejbCreate() in one database operation by using a stored procedure that inserts the corresponding data and retrieves or computes the primary key. Alternatively, you could insert the data and retrieve the corresponding key (or ROWID) in one SQL statement, using the RETURN_GENERATED_KEYS feature in JDBC 3.0. However, the stored procedure approach is more portable across JDBC driver versions and databases.
You can implement this pattern with these three steps:
Create the Java stored procedure, defining a public static Java method insertAccount() within a public GenPK class. This method will insert data, compute a unique key (by passing out a sequence number), and return the computed key as primary key.
Define the Call Spec.
CREATE OR REPLACE PROCEDURE insertAccount(owner IN
varchar, bal IN number, newid OUT number)
AS LANGUAGE JAVA NAME 'GenPK.insertAccount(
java.lang.String [])';
Invoke the stored procedure within ejbCreate().
Public AccountPK ejbCreate(String ownerName, int balance) throws CreateException
try {
CallableStatement call = conn.prepareCall{
"{call insertAccount(?, ?, ?)}"};
return new AccountPK(accountID);
Custom Primary Key Finders for CMP Entity Beans
Finder methods are used for retrieving existing EJB entity bean instances. Primary key finders allow you to retrieve a uniquely identified EJB instance. For CMP entity beans, the EJB container automatically generates the primary key finder findByPrimaryKey() method, based on declarative description. In some situations, however, you might need more control; for example, you may need a specialized finder such as findByStoredProcKey(). In these situations, you can use Java stored procedures in conjunction with an object relational framework (such as Oracle9i Application Server [Oracle9iAS] TopLink) to implement a custom primary key finder method. After you define the EJB finder as a REDIRECT or NAMED finder, TopLink will generate the SQL query for retrieving the bean instance.
Data-Driven EJB Invocation
In a data-driven architecture, business logic invocation can be triggered as a result of database operations (such as inserts, updates, or deletes). A Java stored procedure implementing the data logic can be declared as a database trigger to invoke EJBs running in a middle-tier J2EE application server. You can make EJB calls by using either standard remote method invocation (RMI) over Interoperable Inter-ORB Protocol (IIOP), using a J2EE 1.3 compatible server, or RMI over a vendor-specific transport protocol (such as ORMI with Oracle9iAS/OC4J or RMI over T3 with BEA WebLogic). Each application server vendor has its own optimized protocol while providing RMI over IIOP for interoperability. Oracle9iAS supports both RMI calls over IIOP and ORMI protocols.
Data-Driven Messaging
Oracle9i Database embeds Advanced Queuing (AQ), which is an integrated, persistent, reliable, secure, scalable, and transactional message-queuing framework. Oracle exposes AQ features to Java developers through the standard Java Messaging System (JMS) API. Java stored procedures can invoke AQ operations through the JMS interface to allow fast, intra-session, scalable, data-driven messaging.
Java stored procedures can use JMS to invoke AQ operations. You can implement this pattern in four steps:
Create and start the JMS Queue (to do so, embed the following operations within a SQL script):
execute dbms_aqadm.create_queue_table(queue_table =>
'queue1', queue_payload_type =>
'SYS.AQ$_JMS_TEXT_MESSAGE', comment => 'a test queue',
multiple_consumers => false, compatible => '8.1.0');
execute dbms_aqadm.create_queue( queue_name => 'queue1',
queue_table => 'queue1' );
execute dbms_aqadm.start_queue(queue_name => 'queue1');
Create the Java stored procedure (a code snippet is shown):
public static void runTest(String msgBody)
try
// get database connection
ora_drv = new OracleDriver();
db_conn = ora_drv.defaultConnection();
// setup sender (cf online code sample)
// create message
s_msg = s_session.createTextMessage(msgBody);
// send message
sender.send(s_msg);
s_session.commit();
// receive message
r_msg = (TextMessage) receiver.receive();
r_session.commit();
// output message text
String body = r_msg.getText();
System.out.println("message was '"+body+"'");
Create the Call Spec:
create or replace procedure jmsproc (t1 IN VARCHAR)
as language java name 'jmsSample.main (java.lang.String[])';
Invoke the stored procedure:
call jmsproc('hello');
Database-Assisted Web Publishing (Cache Invalidation)
One of the common issues application architects must face is how to cache database information reliably to increase overall system performance. JCACHE is an upcoming standard specification (JSR 107) that addresses this problem. It specifies an approach for temporary, in-memory caching of Java objects, including object creation, shared access, spooling, invalidation, and consistency across JVMs. It can be used to cache read-mostly data such as product catalogs and price lists within JSP. Using JCACHE, most queries will have response times an order of magnitude faster because of cached data (in-house testing showed response times about 15 times faster).
In order to track all the changes to the origin data and refresh the cached data, a Java stored procedure is attached to a table as a trigger. Any change to this table will result in the automatic invocation of this stored procedure, which in turn will call out a defined JSP to invalidate the JCACHE object that maps its state to the database table. Upon invalidation, the very next query will force the cache to be refreshed from the database. Next Steps
READ MORE about Java Stored Procedures
This article is adapted from the white paper "Unleash the Power of Java Stored Procedures." You can find the white paper at:
/tech/java/java_db/pdf/
OW_30820_JAVA_STORED_PROC_paper.PDF
New PL/SQL features in Oracle9i Database, Release 2
/tech/pl_sql/pdf/
Paper_30720_Doc.pdf
Resolver Spec
/docs/products/oracle9i/
doc_library/release2/java.920/a96659.pdf
OracleJVM and Java 2 Security
/docs/products/oracle9i/
doc_library/release2/java.920/a96656.pdf
DOWNLOAD Code
Exercise code examples from this article:
/sample_code/tech/
java/jsp/Oracle9iJSPSamples.html
LEARN about stored procedures as Web services
/tech/webservices
Extending Database Functionality
One of the great things about running Java code directly in the database is the ability to implement new functionality by simply loading the code or library and using the Call Spec to make the entry points (public static methods) available to SQL, PL/SQL, Java, J2EE, and non-Java APIs. Oracle9i Database customers can easily extend database functionality. Oracle itself leverages this capability for new utilities and packages such as the XML Developer Kits (XDKs).
Bridging SQL, PL/SQL, Java, J2EE, .NET, and XML
The Oracle XDK is written in Java and exposes its public methods as Java stored procedures, extending the database's XML programmability. SQL, PL/SQL, Java, J2EE, and non-Java (.NET) business logic all have access to the XML parser, the XSLT processor, the XPath engine, and XML SQL Utility (XSU).
The XML parser is accessible through the xmlparser and xmldom packages. XSU is a Java utility that generates an XML document from SQL queries or a JDBC ResultSet, and writes data from an XML document into a database table or view. Using XSU, XML output can be produced as Text, DOM trees, or DTDs. XSU is exposed to PL/SQL through the dbms_xmlquery and dbms_xmlsave packages.
Conclusion
The integration of the Oracle database with a Java VM enables the creation of portable, powerful, database-independent data logic and persistence logic. The loose coupling of business logic that runs in the middle tier with data logic that runs in the database tier improves application scalability, performance, flexibility, and maintenance.
Kuassi Mensah ([email protected]) is a product manager in the Server Technologies division at Oracle.
http://otn.oracle.com/oramag/oracle/03-jan/o13java.html
Joel Pérez -
Best method to load XML data into Oracle
Hi,
I have to load XML data into Oracle tables. I tried using different options and have run into a dead end in each of those. I do not have knowledge of java and hence have restricted myself to PL/SQL solutions. I tried the following options.
1. Using DBMS_XMLSave package : Expects the ROWSET and ROW tags. Connot change format of the incoming XML file (Gives error oracle.xml.sql.OracleXMLSQLException: Start of root element expected).
2. Using the XMLPARSER and XMLDOM PL/SQL APIs : Works fine for small files. Run into memory problems for large files (Gives error java.lang.OutOfMemoryError). Have tried increasing the JAVA_POOL_SIZE but does not work. I am not sure whether I am changing the correct parameter.
I have read that the SAX API does not hog memory resources since it does not build the entire DOM tree structure. But the problem is that it does not have a PL/SQL implementation.
Can anyone PLEASE guide me in the right direction, as to the best way to achieve this through PL/SQL ??? I have not designed the tables so am flexible on using purely relational or object-relational design. Although would prefer to keep a purely relational design. (Had tried used object-relational for 1. and purely relational for 2. above)
The XML files are in the following format, (EXAMINEEs with single DEMOGRAPHIC and multiple TESTs)
<?xml version="1.0"?>
<Root_Element>
<Examinee>
<MACode>A</MACode>
<TestingJID>TN</TestingJID>
<ExamineeID>100001</ExamineeID>
<CreateDate>20020221</CreateDate>
<Demographic>
<InfoDate>20020221</InfoDate>
<FirstTime>1</FirstTime>
<LastName>JANE</LastName>
<FirstName>DOE</FirstName>
<MiddleInitial>C</MiddleInitial>
<LithoNumber>73</LithoNumber>
<StreetAddress>SomeAddress</StreetAddress>
<City>SomeCity</City>
<StateCode>TN</StateCode>
<ZipCode>37000</ZipCode>
<PassStatus>1</PassStatus>
</Demographic>
<Test>
<TestDate>20020221</TestDate>
<TestNbr>1</TestNbr>
<SrlNbr>13773784</SrlNbr>
</Test>
<Test>
<TestDate>20020221</TestDate>
<TestNbr>2</TestNbr>
<SrlNbr>13773784</SrlNbr>
</Test>
</Examinee>
</Root_Element>
Thanks for the help.Please refer to the XSU(XML SQL Utility) or TransX Utility(for Multi-language Document) if you want to load data in XML format into database.
Both of them require special XML formats, please first refer to the following docs:
http://otn.oracle.com/docs/tech/xml/xdk_java/doc_library/Production9i/doc/java/xsu/xsu_userguide.html
http://otn.oracle.com/docs/tech/xml/xdk_java/doc_library/Production9i/doc/java/transx/readme.html
You can use XSLT to transform your document to the required format.
If you document is large, you can use SAX method to insert data into database. But you need to write the code.
The following sample may be useful:
http://otn.oracle.com/tech/xml/xdk_sample/xdksample_040602i.html -
I hope someone can help!
Trying to create a sitemap for my organisations new intranet.
I have created a view below to capture the URL to the page.
SELECT p.ID page_id, s.title area, p.siteid, p.parentid, s.ID groupid,
settingssetid,
'<a href="http://croweb02.crown.copfs.gsi.gov.uk:8090/portal/page/portal/'
|| p.guid
|| '">'
|| p.title title
FROM dev_portal.wwv_sites s, dev_portal.wwpob_page$ p
WHERE p.settingssetid = 1422 AND p.siteid > 6 AND s.ID = p.siteid
START WITH p.parentid = 1
CONNECT BY PRIOR p.ID = p.parentid
--GROUP BY siteid, parentid, title, LEVEL, ID, settingssetid, guid
ORDER SIBLINGS BY p.siteid, p.parentid, p.title, p.ID;I have also created a SQL query report to populte the sitemap. However when I run the query only pages were its parentid = 1 has a link been added? How can I correct this to all pages?
select siteid, page_id, area, parentid, LPAD (' ', 6 * (LEVEL - 1)) || title
from dev_portal.view_site_map2
START WITH parentid = 1
CONNECT BY PRIOR page_id = parentid
ORDER SIBLINGS BY siteid, parentid, title, page_idThanks
Edited by: user8951581 on 16-Jun-2011 03:03
Edited by: BluShadow on 16-Jun-2011 11:16
removed poor bold formatting of code and added appropriate {noformat}{noformat} tags.
Please read {message:id=9360002} to learn how to post code and dataI posted an example showing how to build a tree in pl/sql using the xmlparser and xmldom packages.
-
XSLT performance problem in Oracle
Hi,
I'm doing a XSLT in oracle. For this I use the XMLPARSER and XSLPROCESSOR package provided by Oracle.
The function which implements this package has the following code.
function get_XML
(p_product_clob IN clob, p_stylesheet_id IN varchar2) return clob
-- Local variables
l_xslprocessor xslprocessor.PROCESSOR;
l_stylesheet_DOMDoc xmldom.DOMDocument;
l_xml_DOMDoc xmldom.DOMDocument;
l_stylesheet_xmlparser xmlparser.PARSER;
l_xml_xmlparser xmlparser.PARSER;
l_stylesheet xslprocessor.STYLESHEET;
-- to store the xml structure from the int_product_hist table.
l_stylesheet_clob clob; -- to store the xsl to applied to the xml.
l_result_xml clob; --output xml structure.
begin
--create a temporary clob
dbms_lob.createtemporary(l_result_xml,true,dbms_lob.session);
-- Check if the input xml clob variable is empty
if dbms_lob.GETLENGTH(p_product_clob)=0 then
return null;
end if;
-- Check for 205 according to which stylesheet is to be applied.
if rtrim(ltrim(p_stylesheet_id)) is not null then
select STYLESHEET_DESC into l_stylesheet_clob
from SM_XML_STYLESHEETS
where STYLESHEET_ID=p_stylesheet_id;
if sql%notfound then
return null;
end if;
else
return null;
end if;
-- make objects
l_xml_xmlparser := xmlparser.NEWPARSER;
l_stylesheet_xmlparser := xmlparser.NEWPARSER;
l_xslprocessor := xslprocessor.NEWPROCESSOR;
-- Assign a parser to xml and xsl
xmlparser.parseClob(l_xml_xmlparser, p_product_clob);
xmlparser.parseClob(l_stylesheet_xmlparser, l_stylesheet_clob);
l_xml_DOMDoc := xmlparser.GETDOCUMENT(l_xml_xmlparser);
l_stylesheet_DOMDoc := xmlparser.GETDOCUMENT(l_stylesheet_xmlparser);
l_stylesheet:=xslprocessor.NEWSTYLESHEET(l_stylesheet_DOMDoc,null);
-- applying the xsl on xml.
xslprocessor.processXSL(l_xslprocessor, l_stylesheet, l_xml_DOMDoc, l_result_xml);
-- free all objects.
xmlparser.freeParser(l_xml_xmlparser);
xmlparser.freeParser(l_stylesheet_xmlparser);
xslprocessor.freeStylesheet(l_stylesheet);
xslprocessor.freeProcessor(l_xslprocessor);
-- return the xml after xslt.
return l_result_xml;
end;
The xml is sent as a parameter to this function (p_product_clob) and the stylesheet id is sent as input to this function. The stylesheet is picked from the table based on the id passed as parameter.
The function returns a correct output. But it takes a lot of time to do this operation (2 min). My project requirement is 5 sec.
Is there anyway that we can reduce the time for this XSLT.
Regards,
Milton.Would you send sample XML and XSL file? Or at least the XSL file.
Thanks. -
Update passed in XML doc with pl/sql xmldom
Hi,
I have an xml document that is passed in through a stored procedure as CLOB. I'm trying to use the XMLParser and XMLDOM to add an additional node
The XML looks something like the following
<rowset>
<row>
<firstname>john</firstname>
</row>
<row>
<firstname>jane</firstname>
</row>
</rowset>
I need to loop through each of <mynames> nodes and then add another node <lastame> so it looks like the following
<rowset>
<row>
<firstname>john</firstname>
<lastame>smith</lastame>
</row>
<row>
<firstname>jane</firstname>
<lastame>smith</lastame>
</row>
</rowset>
I have the following code
parseClob XMLPARSER.Parser;
newNames XMLDOM.DOMDocument;
tempNode XMLDOM.DOMNode;
mye xmldom.domelement;
item_text xmldom.DOMText;
numofrows number;
nodeList xmldom.DOMNodeList;
newnode xmldom.domnode;
parseClob := xmlparser.newParser;
XMLPARSER.parseClob(parseClob,names);
newNames := XMLPARSER.getDocument(parseClob);
XMLPARSER.freeParser(parseClob);
nodeList := xslprocessor.selectNodes(xmldom.makeNode(newNames), '//rowset/row');
numOfRows := xmldom.getlength(nodeList)-1;
for i in 0..numOfRows LOOP
newnode := xmldom.item(nodeList, i);
--create the new node
mye := xmldom.createElement(newName, 'lastname');
--add it to the new node
tempNode := xmldom.appendChild(newnode, xmldom.makeNode(mye));
--update the text in the lastname
item_text := xmldom.createTextNode(newNames, 'smith');
tempNode := xmldom.appendChild(tempNode, xmldom.makeNode(item_text));
end loop;
what happens is that when i write out the newnode xml out to a buffer i see the <lastname> tag
but when i write out the newNames xml out to a buffer after the loop is finished the <lastname> tag is
missing. like it didn't update the newNames xml
I've seen lots of example on how to create an XML document with the DOM from scratch but nothing about updating
an passed in xml document. any help would be appreciatedUpdatexml is reference in Oracle 9i, I'm sorry i should have mentioned that I am using oracle 8i. Is there something you can use in oracle 8i?
-
SAX Parser Global Variable problem
Can someone tell me what i am doing wrong.
i have a javabean called querybean that i store cdata from an xml file. i also have a map that i want to store this querybean in.
when i debug this, i can see the map being populated in my end element event call, but when i return the map, there is nothing in it.
I'm not really sure why this is. is the calling of the parser events run on a differnt thread or something.
here is my code
public class XmlParsing extends DefaultHandler implements LexicalHandler{
String reportId = null;
boolean cdataSection = false;
StringBuffer cdataString = new StringBuffer();
Map queryMap = new HashMap();
QueryBean queryBean = new QueryBean();
public static final String LEXICAL_SAX_PROPERTY =
"http://xml.org/sax/properties/lexical-handler";
public Map XmlPassThrough(File file)
DefaultHandler handler = new XmlParsing();
SAXParserFactory factory = SAXParserFactory.newInstance();
try
SAXParser saxParser = factory.newSAXParser();
saxParser.setProperty("http://xml.org/sax/properties/lexical-handler",handler);
saxParser.parse(file,handler);
catch(Exception e)
e.printStackTrace();
return this.queryMap;
//////////Setters and Getters////////////////////////////
public String getReportId() {
return reportId;
public void setReportId(String reportId) {
this.reportId = reportId;
public boolean isCdataSection() {
return cdataSection;
public void setCdataSection(boolean cdataSection) {
this.cdataSection = cdataSection;
public StringBuffer getCdataString() {
return cdataString;
public void setCdataString(StringBuffer cdataString) {
this.cdataString = cdataString;
public Map getQueryMap() {
return queryMap;
public void setQueryMap(Map queryMap) {
this.queryMap = queryMap;
/* Handler Methods*/
public void startDocument() throws SAXException{
System.out.println("Start of Document");
public void endDocument() throws SAXException{
System.out.println("End of Document");
public void startElement(String namespaceURI,
String lName,
String qName,
Attributes attrs)
throws SAXException
String eName = lName;
if("".equals(eName)) eName = qName;
if(qName.equals("sql"))
queryBean.setReportID(attrs.getValue("report_id"));
queryBean.setReportType(attrs.getValue("report_type"));
if(attrs.getValue("report_start_date").equals("true"))
queryBean.setReport_start_date(true);
else
queryBean.setReport_start_date(false);
public void endElement(String namespaceURI,
String sName, // simple name
String qName // qualified name
throws SAXException
if(qName.equals("select"))
queryBean.setSelect(this.getCdataString());
else if(qName.equals("from"))
queryBean.setFrom(this.getCdataString());
else if(qName.equals("where"))
queryBean.setWhere(this.getCdataString());
else if(qName.equals("group"))
queryBean.setGroup(this.getCdataString());
else if(qName.equals("order"))
queryBean.setOrder(this.getCdataString());
else if(qName.equals("sql"))
this.queryMap.put(queryBean.getReportID(),queryBean);
this.setQueryMap(queryMap);
this.cdataString.setLength(0);
public void characters(char buf[], int offset, int len)
throws SAXException
if(this.isCdataSection())
String str = new String(buf,offset,len);
this.cdataString.append(str);
/* LexicalHandler Methods*/
public void endCDATA() throws SAXException {
// TODO Auto-generated method stub
System.out.println(this.cdataString.toString());
System.out.println("end of CDATASECTION");
this.setCdataSection(false);
public void endDTD() throws SAXException {
// TODO Auto-generated method stub
public void startCDATA() throws SAXException {
// TODO Auto-generated method stub
System.out.println("Start of CDATASECTION");
this.setCdataSection(true);
public void comment(char[] ch, int start, int length) throws SAXException {
// TODO Auto-generated method stub
public void endEntity(String name) throws SAXException {
// TODO Auto-generated method stub
public void startEntity(String name) throws SAXException {
// TODO Auto-generated method stub
public void startDTD(String name, String publicId, String systemId) throws SAXException {
// TODO Auto-generated method stub
}Well, despite all your copious use of "this" you actually have two instances of your class. You create one, then in its XmlPassThrough method you create a second one to be the handler for the first one. The second one is where you accumulate all your data, and then you return the empty data from the first one.
So remove this line:DefaultHandler handler = new XmlParsing();and replace all references to the "handler" variable by "this". That way your XmlParsing object acts as its own handler and accumulates data in its own fields. -
How to parse an XML document with oracle8i
Has anyone a good link or an example how to decode and store an XML document into an oracle8i database.
I' ve found only good things for oracle9i.
Thank you
RogerHere is an example of parsing xml taken fro Oracle8i 8.1.7 xdk.
This one uses external OS files to pase, but could be easily converted to
use CLOB or VARCHAR2 string for parsing XML documents.
IF you wanted to use CLOB to store and manipulate xml documents you can use XMLParser and XMLDom
packages along with the DBMS_LOB package to do that.
-- This file demonstates a simple use of the parser and DOM API.
-- The XML file that is given to the application is parsed and the
-- elements and attributes in the document are printed.
-- The use of setting the parser options is demonstrated.
set serveroutput on;
create or replace procedure domsample(dir varchar2, inpfile varchar2,
errfile varchar2) is
p xmlparser.parser;
doc xmldom.DOMDocument;
-- prints elements in a document
procedure printElements(doc xmldom.DOMDocument) is
nl xmldom.DOMNodeList;
len number;
n xmldom.DOMNode;
begin
-- get all elements
nl := xmldom.getElementsByTagName(doc, '*');
len := xmldom.getLength(nl);
-- loop through elements
for i in 0..len-1 loop
n := xmldom.item(nl, i);
dbms_output.put(xmldom.getNodeName(n) || ' ');
end loop;
dbms_output.put_line('');
end printElements;
-- prints the attributes of each element in a document
procedure printElementAttributes(doc xmldom.DOMDocument) is
nl xmldom.DOMNodeList;
len1 number;
len2 number;
n xmldom.DOMNode;
e xmldom.DOMElement;
nnm xmldom.DOMNamedNodeMap;
attrname varchar2(100);
attrval varchar2(100);
begin
-- get all elements
nl := xmldom.getElementsByTagName(doc, '*');
len1 := xmldom.getLength(nl);
-- loop through elements
for j in 0..len1-1 loop
n := xmldom.item(nl, j);
e := xmldom.makeElement(n);
dbms_output.put_line(xmldom.getTagName(e) || ':');
-- get all attributes of element
nnm := xmldom.getAttributes(n);
if (xmldom.isNull(nnm) = FALSE) then
len2 := xmldom.getLength(nnm);
-- loop through attributes
for i in 0..len2-1 loop
n := xmldom.item(nnm, i);
attrname := xmldom.getNodeName(n);
attrval := xmldom.getNodeValue(n);
dbms_output.put(' ' || attrname || ' = ' || attrval);
end loop;
dbms_output.put_line('');
end if;
end loop;
end printElementAttributes;
begin
-- new parser
p := xmlparser.newParser;
-- set some characteristics
xmlparser.setValidationMode(p, FALSE);
xmlparser.setErrorLog(p, dir || '/' || errfile);
xmlparser.setBaseDir(p, dir);
-- parse input file
xmlparser.parse(p, dir || '/' || inpfile);
-- get document
doc := xmlparser.getDocument(p);
-- Print document elements
dbms_output.put('The elements are: ');
printElements(doc);
-- Print document element attributes
dbms_output.put_line('The attributes of each element are: ');
printElementAttributes(doc);
-- deal with exceptions
exception
when xmldom.INDEX_SIZE_ERR then
raise_application_error(-20120, 'Index Size error');
when xmldom.DOMSTRING_SIZE_ERR then
raise_application_error(-20120, 'String Size error');
when xmldom.HIERARCHY_REQUEST_ERR then
raise_application_error(-20120, 'Hierarchy request error');
when xmldom.WRONG_DOCUMENT_ERR then
raise_application_error(-20120, 'Wrong doc error');
when xmldom.INVALID_CHARACTER_ERR then
raise_application_error(-20120, 'Invalid Char error');
when xmldom.NO_DATA_ALLOWED_ERR then
raise_application_error(-20120, 'Nod data allowed error');
when xmldom.NO_MODIFICATION_ALLOWED_ERR then
raise_application_error(-20120, 'No mod allowed error');
when xmldom.NOT_FOUND_ERR then
raise_application_error(-20120, 'Not found error');
when xmldom.NOT_SUPPORTED_ERR then
raise_application_error(-20120, 'Not supported error');
when xmldom.INUSE_ATTRIBUTE_ERR then
raise_application_error(-20120, 'In use attr error');
end domsample;
show errors;
Maybe you are looking for
-
Does anyone have a frequency response graph for macbook pro inbuilt mic?
like the title says, any freq. response graphs? and any other performance specs on the mics? want to find out if I could use it to acoustically test a room, witht he right clibrations
-
Cluster multi-block requests were consuming significant database time
Hi, DB : 10.2.0.4 RAC ASM OS : AIX 5.2 64-bit We are facing too much performance issues and CPU idle time becoming 20%.Based on the AWR report , the top 5 events are showing that problem is in cluster side.I placed 1st node AWR report here for your s
-
Good day everyone Im having problems with assigning an agent as a scheduler agent. I am not sure what I am doing wrong. First I start my agent : ./agent.sh -port=20300 Then assign it as a scheduler agent ./agentscheduler.sh -name=unix_agent -port=203
-
Fcp to color how you have got color to work
Hi Guys I am having problems in getting the work flow with color to work and keep asking question on how to fix it , so i am thinking is there any body who would like to share how they got color to work and what setting you use, what formats ect. so
-
I just recently downloaded the new 10.8 software, and all of my PowerPC applications have stopped working. I did some research and I have heard solutions ranging from to re-buy the programs and install again, to Mac has lost the licensing agreement s