org.xquark.xml.xdbc
Interface PreparedXMLStatement

All Superinterfaces:
XMLStatement

public interface PreparedXMLStatement
extends XMLStatement

This prepared statement interface is used for executing parameterized XQuery or XPath prepared statements, setting external variables and obtaining the results (update statements are not supported yet).
Prepared statements allow queries precompilation by the driver.

In order to binds external variables, two kinds of methods are available:


Method Summary
 void clearVariables()
          Clears the current parameters values immediately.
 boolean execute()
          Executes the query statement specified when this object was built with the prepareStatement method (see XMLConnection interface) that may return results.
 XMLResultSet executeQuery()
          Executes the query statement specified when this object was built with the prepareStatement method (see XMLConnection interface) that returns results.
 void setBigDecimal(java.lang.String ns, java.lang.String varName, java.math.BigDecimal value)
          To set the specified variable with a @link java.math.BigDecimal value.
 void setBoolean(java.lang.String ns, java.lang.String varName, boolean value)
          To set the specified variable with a boolean value.
 void setBytes(java.lang.String ns, java.lang.String varName, byte[] value)
          To set the specified variable with a byte array value.
 void setDate(java.lang.String ns, java.lang.String varName, java.util.Date value)
          To set the specified variable with a @link java.util.Date value.
 void setDouble(java.lang.String ns, java.lang.String varName, double value)
          To set the specified variable with a double value.
 void setExternalVariable(java.lang.String ns, java.lang.String varName, java.lang.String value)
          Binds the specified external variable to the current query of the statement.
 void setFloat(java.lang.String ns, java.lang.String varName, float value)
          To set the specified variable with a float value.
 void setInputStream(java.lang.String ns, java.lang.String varName, java.io.InputStream value, int length)
          To set the specified variable with a @link java.io.InputStream value.
 void setLong(java.lang.String ns, java.lang.String varName, long value)
          To set the specified variable with a long value.
 void setObject(java.lang.String ns, java.lang.String varName, java.lang.Object value)
          To set the specified variable with a value inside an object.
 void setString(java.lang.String ns, java.lang.String varName, java.lang.String value)
          To set the specified variable with a String value.
 
Methods inherited from interface org.xquark.xml.xdbc.XMLStatement
close, execute, execute, executeDocumentQuery, executeDocumentQuery, executeQuery, executeQuery, getBaseURI, getConnection, getDocumentSet, getResultSet, setBaseURI
 

Method Detail

setExternalVariable

public void setExternalVariable(java.lang.String ns,
                                java.lang.String varName,
                                java.lang.String value)
                         throws XMLDBCException
Binds the specified external variable to the current query of the statement. Variable value will be parsed and validated.

Parameters:
ns - The namespace of the external variable. Possibly null if the default namespace is to be used.
varName - local name of the external variable. Must not be null.
value - a string that is the value to set for the variable.
Throws:
XMLDBCException - if a data source access error occurs.

setObject

public void setObject(java.lang.String ns,
                      java.lang.String varName,
                      java.lang.Object value)
               throws XMLDBCException
To set the specified variable with a value inside an object. This method has to be used for instance when you own a java object instead of a corresponding primitive type (e.g. Boolean instead of boolean, Long instead of long, etc.).

Parameters:
ns - The namespace of the external variable. Possibly null if the default namespace is to be used.
varName - local name of the external variable. Must not be null.
value - an object that is the value to set for the parameter.
Throws:
XMLDBCException - if a data source access error occurs.

setBigDecimal

public void setBigDecimal(java.lang.String ns,
                          java.lang.String varName,
                          java.math.BigDecimal value)
                   throws XMLDBCException
To set the specified variable with a @link java.math.BigDecimal value. To be used with XML types derived from decimal.

Parameters:
ns - The namespace of the external variable. Possibly null if the default namespace is to be used.
varName - local name of the external variable. Must not be null.
value - a @link java.math.BigDecimal that is the value to set for the variable.
Throws:
XMLDBCException - if a data source access error occurs.

setInputStream

public void setInputStream(java.lang.String ns,
                           java.lang.String varName,
                           java.io.InputStream value,
                           int length)
                    throws XMLDBCException
To set the specified variable with a @link java.io.InputStream value. To be used with XML types derived from Base64Binary or HexBinary.

Parameters:
ns - The namespace of the external variable. Possibly null if the default namespace is to be used.
varName - local name of the external variable. Must not be null.
value - an input stream.
length - the length of given input stream.
Throws:
XMLDBCException - if a data source access error occurs.

setBytes

public void setBytes(java.lang.String ns,
                     java.lang.String varName,
                     byte[] value)
              throws XMLDBCException
To set the specified variable with a byte array value. To be used with XML types derived from Base64Binary or HexBinary.

Parameters:
ns - The namespace of the external variable. Possibly null if the default namespace is to be used.
varName - local name of the external variable. Must not be null.
value - a byte array that is the value to set for the parameter.
Throws:
XMLDBCException - if a data source access error occurs.

setBoolean

public void setBoolean(java.lang.String ns,
                       java.lang.String varName,
                       boolean value)
                throws XMLDBCException
To set the specified variable with a boolean value. To be used with XML types derived from boolean.

Parameters:
ns - The namespace of the external variable. Possibly null if the default namespace is to be used.
varName - local name of the external variable. Must not be null.
value - a boolean that is the value to set for the parameter.
Throws:
XMLDBCException - if a data source access error occurs.

setDate

public void setDate(java.lang.String ns,
                    java.lang.String varName,
                    java.util.Date value)
             throws XMLDBCException
To set the specified variable with a @link java.util.Date value. To be used with XML types derived from all built-in time types.

Parameters:
ns - The namespace of the external variable. Possibly null if the default namespace is to be used.
varName - local name of the external variable. Must not be null.
value - a java.sql.Date that is the value to set for the parameter.
Throws:
XMLDBCException - if a data source access error occurs.

setDouble

public void setDouble(java.lang.String ns,
                      java.lang.String varName,
                      double value)
               throws XMLDBCException
To set the specified variable with a double value. To be used with XML types derived from double.

Parameters:
ns - The namespace of the external variable. Possibly null if the default namespace is to be used.
varName - local name of the external variable. Must not be null.
value - a double that is the value to set for the parameter.
Throws:
XMLDBCException - if a data source access error occurs.

setFloat

public void setFloat(java.lang.String ns,
                     java.lang.String varName,
                     float value)
              throws XMLDBCException
To set the specified variable with a float value. To be used with XML types derived from float.

Parameters:
ns - The namespace of the external variable. Possibly null if the default namespace is to be used.
varName - local name of the external variable. Must not be null.
value - a float that is the value to set for the parameter.
Throws:
XMLDBCException - if a data source access error occurs.

setLong

public void setLong(java.lang.String ns,
                    java.lang.String varName,
                    long value)
             throws XMLDBCException
To set the specified variable with a long value. To be used with XML types derived from integer.

Parameters:
ns - The namespace of the external variable. Possibly null if the default namespace is to be used.
varName - local name of the external variable. Must not be null.
value - a long that is the value to set for the parameter.
Throws:
XMLDBCException - if a data source access error occurs.

setString

public void setString(java.lang.String ns,
                      java.lang.String varName,
                      java.lang.String value)
               throws XMLDBCException
To set the specified variable with a String value. To be used with XML types derived from string.

Parameters:
ns - The namespace of the external variable. Possibly null if the default namespace is to be used.
varName - local name of the external variable. Must not be null.
value - a string that is the value to set for the parameter.
Throws:
XMLDBCException - if a data source access error occurs.

clearVariables

public void clearVariables()
                    throws XMLDBCException
Clears the current parameters values immediately.

Throws:
XMLDBCException - if a data source access error occurs.

execute

public boolean execute()
                throws XMLDBCException
Executes the query statement specified when this object was built with the prepareStatement method (see XMLConnection interface) that may return results. If the query generates results, use the getResultSet() or getDocumentSet() methods to get the set of results.

Returns:
true if there are available resuts, else false.
Throws:
XMLDBCException - if a data source access error occurs.

executeQuery

public XMLResultSet executeQuery()
                          throws XMLDBCException
Executes the query statement specified when this object was built with the prepareStatement method (see XMLConnection interface) that returns results.

Returns:
an XMLResultSet object that contains the data produced by the given query.
Throws:
XMLDBCException - if a data source access error occurs.


Copyright © 2004 Université de Versailles Saint-Quentin, XQuark Group. All rights reserved.