16 package org.zorbaxquery.api.xqj;
18 import java.io.PrintWriter;
19 import java.sql.Connection;
20 import java.util.Enumeration;
21 import java.util.Properties;
22 import javax.xml.xquery.XQException;
30 System.loadLibrary (
"zorba_api" );
36 private int loginTimeout;
38 private Properties properties =
new Properties();
53 if (!properties.isEmpty()) {
58 }
catch ( Exception e ) {
59 throw new XQException(
"Error creating new Zorba Connection Instance");
80 throw new XQException(
"Connection to an XML datasource using an existing JDBC connection is not supported.");
94 if (!properties.isEmpty()) {
99 }
catch ( Exception e ) {
100 throw new XQException(
"Error creating new Zorba Connection Instance");
142 return propertiesAllowed;
155 public void setProperty(String name, String value)
throws XQException {
157 throw new XQException(
"Property name is null.");
159 boolean allowed =
false;
160 for(
int i=0; i<propertiesAllowed.length; i++) {
161 if (propertiesAllowed[i].equals(name)) {
166 properties.setProperty(name, value);
168 throw new XQException(
"Property not allowed.");
183 throw new XQException(
"Property name is null.");
185 boolean allowed =
false;
186 for(
int i=0; i<propertiesAllowed.length; i++) {
187 if (propertiesAllowed[i].equals(name)) {
192 throw new XQException(
"Property name not supported.");
194 return properties.getProperty(name);
208 throw new XQException(
"Properties are null.");
210 boolean allowed =
false;
211 String tmpstr = null;
212 Enumeration em = prprts.keys();
213 while (em.hasMoreElements()) {
215 tmpstr = (String)em.nextElement();
216 for (
int i=0; i<propertiesAllowed.length; i++) {
217 if (propertiesAllowed[i].equals(tmpstr)) {
222 throw new XQException(
"Property [" + tmpstr +
"] not allowed");
227 while (em.hasMoreElements()) {
228 tmpstr = (String)em.nextElement();
229 properties.setProperty(tmpstr, prprts.getProperty(tmpstr));
243 loginTimeout = seconds;