Example Java classes for XML |
Phil Shaw | pshaw@sybase.com | (510) 922-5174 | Anupam Singh | singha@sybase.com | (510) 922-5344 |
sp_configure "Java Services" |
sp_configure "enable java", 1 sp_configure "number of java sockets", 10 |
sp_configure "process object heap", 3000 sp_configure "shared class heap", 3000 |
|
To use these routines you will need jConnect 5.2. See the jConnect installation instructions for the required settings of the CLASSPATH and the environment variables JAVA_HOME and JDBC_HOME.
acme-corp:14322?user=smith&password=xxx acme-corp:14322?user=sa |
An omitted password defaults to the empty password.
Java-SQL example classes: Address, Address2Line, General, Misc, and JDBCExamples.
Basic example Java classes for the Java-SQL feature of ASE 12.0 and 12.5, for use as SQL procedures, functions, and data types.
The SQLJ example class SQLJExamples.
Examples of the SQLJ feature of ASE 12.5: defining SQL names for Java methods, returning result sets and output parameters, and simplified handling of null parameters.
The package jcs.xml, and subpackages jcs.xml.order and jcs.xml.resultset. These packages provide XML facilities for storing and processing XML documents in SQL databases.
The package jcs.util, with classes FileUtil, StringUtil, and ExecSql. These classes have miscellanous convenience methods for client file I-O, strings, and SQL invocation.
setenv CLASSPATH $CLASSPATH":$SYBASE/ASE-12_5/sample/JavaSql/Java-SQL-examples/java-sql-examples.jar" setenv CLASSPATH $CLASSPATH":$SYBASE/ASE-12_5/sample/JavaSql/SQLJ-examples/sqlj-examples.jar" setenv CLASSPATH $CLASSPATH":$SYBASE/ASE-12_5/sample/JavaSql/XML-examples/jcs.jar" |
installjava -f "$SYBASE/ASE-12_5/sample/JavaSql/Java-SQL-examples/java-sql-examples.jar" \ -j "java_sql_examples_jar" -t 200 -U sa -P "" installjava -f "$SYBASE/ASE-12_5/sample/JavaSql/SQLJ-examples/sqlj-examples.jar" \ -j "sqlj_examples_jar" -t 200 -U sa -P "" installjava -f "$SYBASE/ASE-12_5/sample/JavaSql/XML-examples/jcs.jar" -j "jcs_jar" -t 200 -U sa -P "" |
These actions can be performed with commands such as the following, referencing the copy of the Xerces jar file distributed with ASE 12.5:
|
The Javadoc pages contain the specifications for the classes. Javadoc for the jcs package is in the doc directory.
The examples in the following sections are rudimentary tests to verify that the classes have been setup successfully. The examples don't describe the methods that are being called or their parameters. See the Javadoc pages or the JCS user's manual for that information.
The main methods of the DoSql2Xml and DoXml2Sql classes provide client-side command-line invocation of those SQL-XML and XML-SQL capabilities.
The detailed specifications for those classes and their parameters are specified in the Javadoc pages. The following is a simple introductory example.
java jcs.xml.resultset.DoSql2Xml -S jConnect-server-name -O client-output.xml \ -N yes -C none \ -Q "select 1 as 'a', 2 as 'b', 3 " java jcs.xml.resultset.DoXml2Sql -I client-output.xml \ -O client-output.script -X "column_" -T clientcopy isql -i client-output.script -Usa -P "" |
This script performs the same actions as in the preceeding section:
The trivial SQL query is "select 1 as 'a', 2 as 'b', 3 ". I.e. the query doesn't even reference a table.
The script is as follows (see file test-install/server-script.sql):
|
a b column_3 ----------- ----------- ----------- 1 2 3 (1 row affected) |
|
The results will be in files test-output.xml and test-output.script.
|
|
Note: When the SQL script is generated, a parameter indicates whether you want to include the "go" commands. These are required when the script is executed by ISQL, and not allowed when the script is executed with a JDBC call. Therefore, the above client-side example includes the "go" commands and the server-side example omits them. See the Javadoc pages and the JCS user's manual for further discussion of this option.
|
The changes made in the example classes from ASE 12.0 are as follows:
Call | Result | ||
---|---|---|---|
|
| ||
|
|