public interface XQDataSource
XQDataSource
is a factory for XQConnection
objects. The datasource may be obtained from a JNDI source or through other means.
XQConnection
) objects may be created using
an existing JDBC connection. This is an optional feature that may not be
supported by all implementations. If the implementation supports this
mechanism, then the XQuery connection may inherit some of the JDBC
connection's properties, such as login timeout, log writer etc.
Modifier and Type | Method and Description |
---|---|
XQConnection |
getConnection()
Attempts to create a connection to an XML datasource.
|
XQConnection |
getConnection(Connection con)
Attempts to create a connection to an XML datasource using an
existing JDBC connection.
|
XQConnection |
getConnection(String username,
String passwd)
Attempts to establish a connection to an XML datasource using the
supplied username and password.
|
int |
getLoginTimeout()
Gets the maximum time in seconds that this datasource can wait while
attempting to connect to a database.
|
PrintWriter |
getLogWriter()
Retrieves the log writer for this
XQDataSource object. |
String |
getProperty(String name)
Returns the current value of the named property if set, else
null . |
String[] |
getSupportedPropertyNames()
Returns an array containing the property names supported by this
XQDataSource . |
void |
setLoginTimeout(int seconds)
Sets the maximum time in seconds that this datasource will wait while
attempting to connect to a database.
|
void |
setLogWriter(PrintWriter out)
Sets the log writer for this
XQDataSource object to the given
java.io.PrintWriter object. |
void |
setProperties(Properties props)
Sets the data source properties from the specified
Properties
instance. |
void |
setProperty(String name,
String value)
Sets the named property to the specified value.
|
XQConnection getConnection() throws XQException
XQException
- if a datasource access error occursXQConnection getConnection(Connection con) throws XQException
XQException
)
is thrown. The XQJ and JDBC connections will operate under the same
transaction context.con
- an existing JDBC connectionXQException
- if (1) a datasource access error occurs,
(2) the implementation does not support
this method of getting an
XQConnection
, or (3) if
the con
parameter is null
XQConnection getConnection(String username, String passwd) throws XQException
username
- the user on whose behalf the connection
is being madepasswd
- the user's passwordXQException
- if a datasource access error occursint getLoginTimeout() throws XQException
XQException
- if a datasource access error occursPrintWriter getLogWriter() throws XQException
XQDataSource
object.
The log writer is a character output stream to which all logging and
tracing messages for this datasource will be printed. This includes
messages printed by the methods of this object, messages printed by
methods of other objects manufactured by this object, and so on.
When a XQDataSource
object is created, the log writer is
initially null
; in other words, the default is for logging
to be disabled.null
if logging is disabledXQException
- if a datasource access error occursString[] getSupportedPropertyNames()
XQDataSource
.
Implementations that support user name and password must recognize
the user name and password properties listed below.
user |
the user name to use for creating a connection |
password |
the password to use for creating a connection |
String[]
an array of property names
supported by this implementationvoid setProperty(String name, String value) throws XQException
If the implementation does not support the given property or if it can determine that the value given for this property is invalid, then an exception is thrown. If an exception is thrown, then no previous value is overwritten.
name
- the name of the property to setvalue
- the value of the named propertyXQException
- if (1) the given property is not recognized,
(2) the value for the given property is
determined to be invalid, or (3) the name
parameter is null
String getProperty(String name) throws XQException
null
. If the implementation does not support the
given property then an exception is raised.name
- the name of the property whose value is
neededString
representing the value of
the required property if set, else
null
XQException
- if (1) a given property is not supported, or
(2) the name parameter is null
void setProperties(Properties props) throws XQException
Properties
instance. Properties set before this call will still apply but
those with the same name as any of these properties will be replaced.
Properties set after this call also apply and may
replace properties set during this call.If the implementation does not support one or more of the given property names, or if it can determine that the value given for a specific property is invalid, then an exception is thrown. If an exception is thrown, then no previous value is overwritten. is invalid, then an exception is raised.
props
- the list of properties to setXQException
- if (1) a given property is not recognized,
(2) the value for a given property is
determined to be invalid, or (3) the
props
parameter is null
void setLoginTimeout(int seconds) throws XQException
XQDataSource
object is created, the login timeout is initially zero.
It is implementation-defined whether the specified login timeout is
actually used by the data source implementation. If the connection is
created over an existing JDBC connection, then the login timeout
value from the underlying JDBC connection may be used.seconds
- the datasource login time limitXQException
- if a datasource access error occursvoid setLogWriter(PrintWriter out) throws XQException
XQDataSource
object to the given
java.io.PrintWriter
object. The log writer is a character output
stream to which all logging and tracing messages for this datasource
will be printed. This includes messages printed by the methods of this
object, messages printed by methods of other objects manufactured by
this object, and so on. When a XQDataSource
object is created
the log writer is initially null
; in other words, the default
is for logging to be disabled.out
- the new log writer; to disable logging, set to
null
XQException
- if a datasource access error occursCopyright (c) 2004-2013 Saxonica Limited. All rights reserved.