|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
A connection (session) with a specific XQuery engine. Connections are
obtained through an XQDataSource object.
XQuery expressions are executed and results are returned within the
context of a connection. They are either executed through XQExpression
or XQPreparedExpression objects.
XQDataSource ds;// obtain the XQuery datasource
...
XQConnection conn = ds.getConnection();
XQPreparedExpression expr = conn.prepareExpression("for $i in ...");
XQResultSequence result = expr.executeQuery();
// - or -
XQExpression expr = conn.createExpression();
XQSequence result = expr.executeQuery("for $i in..");
// The sequence can now be iterated
while (result.next())
{
String str = result.getItemAsString();
System.out.println(" output "+ str);
}
result.close();
expr.close();
conn.close(); // close the connection and free all resources..
A connection has the following properties. These properties affect the
sequences obtained through the execution of XQuery expressions in the
context of the connection.
By default a connection operates in auto-commit mode, which means that
each xquery is executed and committed in an individual transaction. If
auto-commit mode is disabled, a transaction must be ended explicitly by
the application calling commit() or
rollback().
When the XQConnection is closed any XQExpression
and XQPreparedExpression objects obtained from it are also
implicitly closed.
| Method Summary | |
void |
clearWarnings()
Clears the list of warnings associated with this connection. |
void |
close()
Closes the connection. |
void |
commit()
Makes all changes made in the current transaction permanent and releases any locks held by the datasource. |
XQExpression |
createExpression()
Creates a new XQExpression object that can be used to perform
execute immediate operations with XQuery expressions. |
XQExpression |
createExpression(XQStaticContext staticContext)
Creates a new XQExpression object that can be used to perform execute
immediate operations with XQuery expressions. |
boolean |
getAutoCommit()
Gets the auto-commit attribute of this connection |
XQMetaData |
getMetaData()
Gets the metadata for this connection. |
String |
getMetaDataProperty(String key)
Gets the value of the connection property indicated by the specified key. |
XQStaticContext |
getStaticContext()
Gets an XQStaticContext representing the default values for all
expression properties. |
String[] |
getSupportedMetaDataPropertyNames()
Determines the property names supported by this connection. |
XQWarning |
getWarnings()
Gets the first warning in a chained list of warnings associated with this connection. |
boolean |
isClosed()
Checks if the connection is closed. |
XQPreparedExpression |
prepareExpression(InputStream xquery)
Prepares an expression for execution. |
XQPreparedExpression |
prepareExpression(InputStream xquery,
XQStaticContext staticContext)
Prepares an expression for execution. |
XQPreparedExpression |
prepareExpression(Reader xquery)
Prepares an expression for execution. |
XQPreparedExpression |
prepareExpression(Reader xquery,
XQStaticContext staticContext)
Prepares an expression for execution. |
XQPreparedExpression |
prepareExpression(String xquery)
Prepares an expression for execution. |
XQPreparedExpression |
prepareExpression(String xquery,
XQStaticContext staticContext)
Prepares an expression for execution. |
void |
rollback()
Undoes all changes made in the current transaction and releases any locks held by the datasource. |
void |
setAutoCommit(boolean autoCommit)
Sets the auto-commit attribute to the given state. |
void |
setStaticContext(XQStaticContext staticContext)
Sets the default values for all expression properties. |
| Method Detail |
public void close()
throws XQException
XQExpression and
XQPreparedExpression obtained from this connection.
Once the connection is closed, no method other than close
or the isClosed method may be called on the connection object.
Calling close on an XQConnection object that is already closed
has no effect.
Note that an XQJ driver is not required to provide finalizer methods for
the connection and other objects. Hence it is strongly recommended that
users call this method explicitly to free any resources. It is also
recommended that they do so under a final block to ensure that the object
is closed even when there are exceptions.
XQException - if there is an error during closing the connection.
public void commit()
throws XQException
XQResultSequence, or XQResultItem may be implicitly
closed upon commit, if the holdability property of the sequence is set to
XQConstants.HOLDTYPE_CLOSE_CURSORS_AT_COMMIT.
XQException - if the connection is in a closed state or this
connection is operating in auto-commit mode.
public void clearWarnings()
throws XQException
XQException - if the connection is in a closed state.
public XQExpression createExpression()
throws XQException
XQExpression object that can be used to perform
execute immediate operations with XQuery expressions. The properties of the
connection's default XQStaticContext are copied to the returned
XQExpression.
XQExpression that can be used to execute
multiple expressions
XQException - if the connection is in a closed state
public XQExpression createExpression(XQStaticContext staticContext)
throws XQException
XQExpression object that can be used to perform execute
immediate operations with XQuery expressions. The properties of the specified
XQStaticContext values are copied to the returned XQExpression.
staticContext - an XQStaticContext representing
the default values for this expression
XQExpression that can be used to execute
multiple expressions
XQException - if (1) the connection is in a closed state, or
(2) the specified argument is null
public String[] getSupportedMetaDataPropertyNames()
throws XQException
| Key | Description of Associated Value |
|---|---|
com.ddtek.xquery3.metadata.ProductVersion |
XQuery Product Version |
com.ddtek.xquery3.metadata.ProductName |
XQuery Product Name |
com.ddtek.xquery3.metadata.XQJVersion |
XQuery API for Java Version |
com.ddtek.xquery3.metadata.SchemaImportSupported |
Whether Schema Import feature is supported ('true' indicates yes and 'false' indicates no) |
com.ddtek.xquery3.metadata.StaticTypingSupported |
Whether Static Typing feature is supported ('true' indicates yes and 'false' indicates no) |
com.ddtek.xquery3.metadata.FullAxisSupported |
Whether Full Axis feature is supported ('true' indicates yes and 'false' indicates no) |
com.ddtek.xquery3.metadata.ModuleSupported |
Whether Module feature is supported ('true' indicates yes and 'false' indicates no) |
com.ddtek.xquery3.metadata.PragmaSupported |
Whether Pragma feature is supported ('true' indicates yes and 'false' indicates no) |
com.ddtek.xquery3.metadata.MustUnderstandExtensionsSupported |
Whether Must Understand Extensions feature is supported ('true' indicates yes and 'false' indicates no) |
com.ddtek.xquery3.metadata.StaticTypingExtensionsSupported |
Whether Static Typing Extensions feature is supported ('true' indicates yes and 'false' indicates no) |
com.ddtek.xquery3.metadata.XQueryXSupported |
Whether XQueryX is supported ('true' indicates yes and 'false' indicates no) |
com.ddtek.xquery3.metadata.CollectionNestingSupported |
Whether Nested Collections are supported ('true' indicates yes and 'false' indicates no) |
com.ddtek.xquery3.metadata.ReadOnly |
Whether the connection is a read only connection ('true' indicates yes and 'false' indicates no) |
com.ddtek.xquery3.metadata.TransactionSupported |
Whether the connection supports transactions ('true' indicates yes and 'false' indicates no) |
com.ddtek.xquery3.metadata.CreatedFromJDBCConnection |
Whether the connection was created from an existing JDBC connection ('true' indicates yes and 'false' indicates no) |
com.ddtek.xquery3.metadata.MaxExpressionLength |
String representation of the maximum length of the xquery string supported on this connection. A value of zero means that there is no limit or the limit is unknown |
com.ddtek.xquery3.metadata.MaxUserNameLength |
String representing the maximum length of a valid user-name on this connection. A value of zero means that there is no limit or the limit is unknown |
com.ddtek.xquery3.metadata.UserName |
The user-name of this connection |
XQException - if the connection is in a closed state
public String getMetaDataProperty(String key)
throws XQException
key - the name of the connection property
null if there is no property with
that key
XQException - if the connection is in a closed state
public XQMetaData getMetaData()
throws XQException
XQMetadata representing the metadata of
this connection
XQException - if the connection is in a closed state
public XQWarning getWarnings()
throws XQException
null.
XQException - if the connection is in a closed statepublic boolean isClosed()
true if the connection is in a closed state,
false otherwise
public XQPreparedExpression prepareExpression(String xquery)
throws XQException
XQStaticContext are copied to the returned
XQPreparedExpression.
xquery - the XQuery expression as an String
XQException - if (1) the connection is in a closed state,
or (2) there are errors preparing the expression
or (3) the specified argument is null.
public XQPreparedExpression prepareExpression(String xquery,
XQStaticContext staticContext)
throws XQException
XQStaticContext values are copied to the returned
XQPreparedExpression.
xquery - the XQuery expression as an StringstaticContext - an XQStaticContext representing
the default values for this expression
XQException - if (1) the connection is in a closed state,
or (2) there are errors preparing the expression
or (3) the specified argument is null.
public XQPreparedExpression prepareExpression(Reader xquery)
throws XQException
XQStaticContext are copied to the returned
XQPreparedExpression.
xquery - the XQuery expression as an Reader
XQException - if (1) the connection is in a closed state,
or (2) there are errors preparing the expression
or (3) the specified argument is null.
public XQPreparedExpression prepareExpression(Reader xquery,
XQStaticContext staticContext)
throws XQException
XQStaticContext values are copied to the returned
XQPreparedExpression.
xquery - the XQuery expression as an ReaderstaticContext - an XQStaticContext representing
the default values for this expression
XQException - if (1) the connection is in a closed state,
or (2) there are errors preparing the expression
or (3) the specified argument is null.
public XQPreparedExpression prepareExpression(InputStream xquery)
throws XQException
XQStaticContext are copied to the returned
XQPreparedExpression.
xquery - the XQuery expression as an InputStream
XQException - if (1) the connection is in a closed state,
or (2) there are errors preparing the expression
or (3) tthe specified argument is null.
public XQPreparedExpression prepareExpression(InputStream xquery,
XQStaticContext staticContext)
throws XQException
XQStaticContext values are copied to the returned
XQPreparedExpression.
xquery - the XQuery expression as an InputStreamstaticContext - an XQStaticContext representing
the default values for this expression
XQException - if (1) the connection is in a closed state,
or (2) there are errors preparing the expression
or (3) the specified argument is null.
public void rollback()
throws XQException
XQException - if the connection is in a closed state or this
connection is operating in auto-commit mode.
public XQStaticContext getStaticContext()
throws XQException
XQStaticContext representing the default values for all
expression properties. In order to modify the defaults, it is not sufficient
to modify the values in the returned XQStaticContext object; in
addition setStaticContext should be called to make those new
values effective.
XQStaticContext representing
the default values for all expression properties.
XQException - if the connection is in a closed state.
public void setStaticContext(XQStaticContext staticContext)
throws XQException
XQStaticContext
and update its private copy.
staticContext - an XQStaticContext representing
the default values
XQException - if (1) the connection is in a closed state,
or (2) if the XQStaticContext is not
valid.
public boolean getAutoCommit()
throws XQException
true if the
connection operates in auto-commit mode; otherwise false.
XQException - if the connection is in a closed state
public void setAutoCommit(boolean autoCommit)
throws XQException
commit() or rollback().
autoCommit - true to enable auto-commit mode; false to disable it
XQException - if the connection is in a closed state
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||