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;
int getLoginTimeout()
Gets the maximum time in seconds that this datasource can wait while attempting to connect to a datab...
void setLoginTimeout(int seconds)
Sets the maximum time in seconds that this datasource will wait while attempting to connect to a data...
An ZorbaXQDataSource is a factory for ZorbaXQConnection objects.
A connection (session) with a specific XQuery engine.
String getProperty(String name)
Returns the current value of the named property if set, else null.
ZorbaXQConnection getConnection(Connection cnctn)
Attempts to create a connection to an XML datasource using an existing JDBC connection.
static final String ZORBA_PROPERTIES_URI_PATHS
static final String ZORBA_PROPERTIES_LIB_PATHS
void setLogWriter(PrintWriter writer)
Sets the log writer for this ZorbaXQDataSource object to the given java.io.PrintWriter object...
static final String ZORBA_PROPERTIES_MODULE_PATHS
PrintWriter getLogWriter()
Retrieves the log writer for this ZorbaXQDataSource object.
String[] getSupportedPropertyNames()
Returns an array containing the property names supported by this ZorbaXQDataSource.
void setProperties(Properties prprts)
Sets the data source properties from the specified Properties instance.
ZorbaXQConnection getConnection(String username, String passwd)
Attempts to establish a connection to an XML datasource using the supplied username and password...
ZorbaXQConnection getConnection()
Attempts to create a connection to an XML datasource.
void setProperty(String name, String value)
Sets the named property to the specified value.