X

Proactive insights, news and tips from Oracle Fusion Middleware Support. Learn Oracle from Oracle.

Using SQLXML Data Type with Application Continuity

Stephen Felts
Manager

When I first wrote an article about changing Oracle
concrete classes to interfaces to work with Application Continuity (AC) (https://blogs.oracle.com/WebLogicServer/entry/using_oracle_jdbc_type_interfaces),
I left out one type. oracle.sql.OPAQUE
is replaced with oracle.jdbc.OracleOpaque. There isn’t a lot that you can do with this opaque type. While the original class had a lot of
conversion methods, the new Oracle type interfaces have only methods that are considered significant or not available with standard JDBC API’s. The new interface only has a method to get
the value as an Object and two meta information methods to get meta data and
type name. Unlike the other Oracle type
interfaces (oracle.jdbc.OracleStruct extends java.sql.Struct and
oracle.jdbc.OracleArray extends java.sql.Array), oracle.jdbc.OracleOpaque does not extend a
JDBC interface

There is one related very common use case that needs
to be changed to work with AC. Early
uses of SQLXML made use of the following XDB API.

SQLXML sqlXml = oracle.xdb.XMLType.createXML(
((oracle.jdbc.OracleResultSet)resultSet).getOPAQUE("issue"));

oracle.xdb.XMLType extends oracle.sql.OPAQUE and its
use will disable AC replay. This must be replaced with the standard JDBC API

SQLXML sqlXml =
resultSet.getSQLXML("issue");

If you try to do a “new oracle.xdb.XMLType(connection,
string)” when running with the replay datasource, you will get a ClassCastException. Since XMLType
doesn’t work with the replay datasource and the oracle.xdb package uses XMLType
extensively, this package is no longer usable for AC replay.

The API’s for SQLXML are documented at https://docs.oracle.com/javase/7/docs/api/java/sql/SQLXML.html. The javadoc shows API’s to work with DOM,
SAX, StAX, XLST, and XPath.

Take a look at the sample program at //cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/f4a5b21d-66fa-4885-92bf-c4e81c06d916/File/e57d46dd27d26fbd6aeeb884445dd5b3/xmlsample.txt

The sample uses StAX to store the information and
DOM to get it. By default, it uses the
replay datasource and it does not use XDB.

You can run with replay debugging by doing something
like the following. Create a file named /tmp/config.txt that has the following
text.

java.util.logging.ConsoleHandler.formatter =
java.util.logging.SimpleFormatter

handlers = java.util.logging.FileHandler

java.util.logging.FileHandler.pattern = /tmp/replay.log

oracle.jdbc.internal.replay.level = FINEST

Change your WLS CLASSPATH (or one with the Oracle client jar files) to put ojdbc7_g.jar at the
front (to replace ojdbc7.jar) and add the current directory.

Compile the program (after renaming .txt to .java)
and run it using

java -Djava.util.logging.config.file=/tmp/config.txt
XmlSample

The output replay log is in /tmp/replay.log. With the defaults in the sample program, you
won’t see replay disabled in the log. If
you change the program to set useXdb to true, you will see that replay is
disabled. The log will have “DISABLE
REPLAY in preForMethodWithConcreteClass(getOPAQUE)” and “Entering
disableReplayInternal”.

This sample can be used to test other sequences of
operations to see if they are safe for replay.

Alternatively, you can use orachk to do a static
analysis of the class. See https://blogs.oracle.com/WebLogicServer/entry/using_orachk_to_clean_up
for more information. If you run orachk
on this program, you will get this failure.

FAILED - [XmlSample][[MethodCall] desc=
(Ljava/lang/String;)Loracle/sql/OPAQUE; method name=getOPAQUE, lineno=105]

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
Oracle

Integrated Cloud Applications & Platform Services