fr.paris.lutece.util.sql
Class DAOUtil

java.lang.Object
  extended by fr.paris.lutece.util.sql.DAOUtil

public class DAOUtil
extends java.lang.Object

Prepared statement util class

Since:
version 1.3

Field Summary
static java.lang.String MSG_EXCEPTION_SELECT_ERROR
           
 
Constructor Summary
DAOUtil(java.lang.String sql)
          Creates a new DAOUtil object.
DAOUtil(java.lang.String strSQL, Plugin plugin)
          Creates a new DAOUtil object.
 
Method Summary
 void executeQuery()
          Executes a query
 void executeUpdate()
          Executes the update request and throws an error if the result is not 1
protected  void finalize()
          finalize implementation
 boolean first()
          Deprecated.  
 void free()
          Free connection
 java.io.InputStream getBinaryStream(int nIndex)
          Gets a binary stream from a resultSet
 java.sql.Blob getBlob(int nIndex)
          Gets a blob from a resultset
 java.sql.Blob getBlob(java.lang.String strColumnName)
          Gets a blob from a resultset
 boolean getBoolean(int nIndex)
          Gets the value of the designated column in the current row of this ResultSet object as a Boolean
 boolean getBoolean(java.lang.String strColumnName)
          Gets the value of the designated column in the current row of this ResultSet object as a Boolean
 byte[] getBytes(int nIndex)
          Gets a byte array from a resultset
 byte[] getBytes(java.lang.String strColumnName)
          Gets a byte array from a resultset
 java.sql.Date getDate(int nIndex)
          Gets the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language.
 java.sql.Date getDate(java.lang.String strColumnName)
          Gets the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language.
 double getDouble(int nIndex)
          Gets the value of the designated column in the current row of this ResultSet object as a double
 double getDouble(java.lang.String strColumnName)
          Gets the value of the designated column in the current row of this ResultSet object as a double
 int getInt(int nIndex)
          Gets the value of the designated column in the current row of this ResultSet object as a int
 int getInt(java.lang.String strColumnName)
          Gets the value of the designated column in the current row of this ResultSet object as a int
 java.lang.Object getObject(int nIndex)
          Gets the value of the designated column in the current row of this ResultSet object as a Object
 java.lang.Object getObject(java.lang.String strColumnName)
          Gets the value of the designated column in the current row of this ResultSet object as an Object
 java.sql.ResultSet getResultSet()
          Get the ResultSet
 java.lang.String getString(int nIndex)
          Gets the value of the designated column in the current row of this ResultSet object as a string
 java.lang.String getString(java.lang.String strColumnName)
          Gets the value of the designated column in the current row of this ResultSet object as a string
 java.sql.Time getTime(int nIndex)
          Gets the value of the designated column in the current row of this ResultSet object as a java.sql.Time object in the Java programming language.
 java.sql.Time getTime(java.lang.String strColumnName)
          Gets the value of the designated column in the current row of this ResultSet object as a java.sql.Time object in the Java programming language.
 java.sql.Timestamp getTimestamp(int nIndex)
          Gets the value of the designated column in the current row of this ResultSet object as a timestamp
 java.sql.Timestamp getTimestamp(java.lang.String strColumnName)
          Gets the value of the designated column in the current row of this ResultSet object as a Timestamp
 boolean isLast()
          Indicates whether the cursor is on the last row of this ResultSet object.
 boolean next()
          Moves the cursor down one row from its current position in the ResultSet.
 void setBinaryStream(int nIndex, java.io.InputStream iStream, int nBlength)
          Fills the prepared statement with a binary value stream
 void setBoolean(int nIndex, boolean bValue)
          Fills the prepared statement with a Boolean value
 void setBytes(int nIndex, byte[] tbValue)
          Fills the prepared statement with a byte array value
 void setDate(int nIndex, java.sql.Date date)
          Fills the prepared statement with a date value
 void setDouble(int nIndex, double dValue)
          Fills the prepared statement with a double value
 void setInt(int nIndex, int nValue)
          Fills the prepared statement with a int value
 void setIntNull(int nIndex)
          Fills the prepared statement with a int null value
 void setString(int nIndex, java.lang.String strValue)
          Fills the prepared statement with a string value
 void setTime(int nIndex, java.sql.Time time)
          Fills the prepared statement with a time value
 void setTimestamp(int nIndex, java.sql.Timestamp ts)
          Fills the prepared statement with a timestamp value
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MSG_EXCEPTION_SELECT_ERROR

public static final java.lang.String MSG_EXCEPTION_SELECT_ERROR
See Also:
Constant Field Values
Constructor Detail

DAOUtil

public DAOUtil(java.lang.String sql)
Creates a new DAOUtil object.

Parameters:
sql - Sql Query for prepared Statement

DAOUtil

public DAOUtil(java.lang.String strSQL,
               Plugin plugin)
Creates a new DAOUtil object.

Parameters:
strSQL - sql query for prepared Statement
plugin - The plugin using this database access
Method Detail

executeUpdate

public void executeUpdate()
Executes the update request and throws an error if the result is not 1


executeQuery

public void executeQuery()
Executes a query


free

public void free()
Free connection


first

public boolean first()
Deprecated. 

Moves the cursor to the first row in this ResultSet object.

Returns:
true if the cursor is on a valid row; false if there are no rows in the result set

isLast

public boolean isLast()
Indicates whether the cursor is on the last row of this ResultSet object.

Returns:
true if the cursor is on the last row; false otherwise

setDate

public void setDate(int nIndex,
                    java.sql.Date date)
Fills the prepared statement with a date value

Parameters:
nIndex - parameter index
date - date value

setTime

public void setTime(int nIndex,
                    java.sql.Time time)
Fills the prepared statement with a time value

Parameters:
nIndex - parameter index
time - time value

setBinaryStream

public void setBinaryStream(int nIndex,
                            java.io.InputStream iStream,
                            int nBlength)
Fills the prepared statement with a binary value stream

Parameters:
nIndex - parameter index
iStream - the java input stream which contains the binary parameter value
nBlength - the number of bytes in the stream

getBinaryStream

public java.io.InputStream getBinaryStream(int nIndex)
Gets a binary stream from a resultSet

Parameters:
nIndex - column index
Returns:
InputStream instance

getBlob

public java.sql.Blob getBlob(int nIndex)
Gets a blob from a resultset

Parameters:
nIndex - column index
Returns:
Blob instance

getBlob

public java.sql.Blob getBlob(java.lang.String strColumnName)
Gets a blob from a resultset

Parameters:
strColumnName - column name
Returns:
Blob instance

getBytes

public byte[] getBytes(int nIndex)
Gets a byte array from a resultset

Parameters:
nIndex - column index
Returns:
byte[] instance

getBytes

public byte[] getBytes(java.lang.String strColumnName)
Gets a byte array from a resultset

Parameters:
strColumnName - column name
Returns:
byte[] instance

setInt

public void setInt(int nIndex,
                   int nValue)
Fills the prepared statement with a int value

Parameters:
nIndex - parameter index in the prepared statement
nValue - int value

setBoolean

public void setBoolean(int nIndex,
                       boolean bValue)
Fills the prepared statement with a Boolean value

Parameters:
nIndex - parameter index in the prepared statement
bValue - Boolean value

setBytes

public void setBytes(int nIndex,
                     byte[] tbValue)
Fills the prepared statement with a byte array value

Parameters:
nIndex - parameter index in the prepared statement
tbValue - byte array value

setString

public void setString(int nIndex,
                      java.lang.String strValue)
Fills the prepared statement with a string value

Parameters:
nIndex - parameter index in the prepared statement
strValue - string value

setTimestamp

public void setTimestamp(int nIndex,
                         java.sql.Timestamp ts)
Fills the prepared statement with a timestamp value

Parameters:
nIndex - parameter index in the prepared statement
ts - timestamp value

setDouble

public void setDouble(int nIndex,
                      double dValue)
Fills the prepared statement with a double value

Parameters:
nIndex - parameter index in the prepared statement
dValue - The value

getDate

public java.sql.Date getDate(int nIndex)
Gets the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language.

Parameters:
nIndex - the first column is 1, the second is 2, ...
Returns:
the column value; if the value is SQL NULL, the value returned is null

getDate

public java.sql.Date getDate(java.lang.String strColumnName)
Gets the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language.

Parameters:
strColumnName - name of the column, ...
Returns:
the column value; if the value is SQL NULL, the value returned is null

getTime

public java.sql.Time getTime(int nIndex)
Gets the value of the designated column in the current row of this ResultSet object as a java.sql.Time object in the Java programming language.

Parameters:
nIndex - the first column is 1, the second is 2, ...
Returns:
the column value; if the value is SQL NULL, the value returned is null

getTime

public java.sql.Time getTime(java.lang.String strColumnName)
Gets the value of the designated column in the current row of this ResultSet object as a java.sql.Time object in the Java programming language.

Parameters:
strColumnName - name of the column, ...
Returns:
the column value; if the value is SQL NULL, the value returned is null

getInt

public int getInt(int nIndex)
Gets the value of the designated column in the current row of this ResultSet object as a int

Parameters:
nIndex - the first column is 1, the second is 2, ...
Returns:
the column value; if the value is SQL NULL, the value returned is 0

getInt

public int getInt(java.lang.String strColumnName)
Gets the value of the designated column in the current row of this ResultSet object as a int

Parameters:
strColumnName - column name
Returns:
the column value; if the value is SQL NULL, the value returned is 0

getBoolean

public boolean getBoolean(int nIndex)
Gets the value of the designated column in the current row of this ResultSet object as a Boolean

Parameters:
nIndex - the first column is 1, the second is 2, ...
Returns:
the column value; if the value is SQL NULL, the value returned is FALSE

getBoolean

public boolean getBoolean(java.lang.String strColumnName)
Gets the value of the designated column in the current row of this ResultSet object as a Boolean

Parameters:
strColumnName - column name
Returns:
the column value; if the value is SQL NULL, the value returned is FALSE

getString

public java.lang.String getString(int nIndex)
Gets the value of the designated column in the current row of this ResultSet object as a string

Parameters:
nIndex - the first column is 1, the second is 2, ...
Returns:
the column value; if the value is SQL NULL, the value returned is NULL

getString

public java.lang.String getString(java.lang.String strColumnName)
Gets the value of the designated column in the current row of this ResultSet object as a string

Parameters:
strColumnName - column name
Returns:
the column value; if the value is SQL NULL, the value returned is NULL

getTimestamp

public java.sql.Timestamp getTimestamp(int nIndex)
Gets the value of the designated column in the current row of this ResultSet object as a timestamp

Parameters:
nIndex - the first column is 1, the second is 2, ...
Returns:
the column value; if the value is SQL NULL, the value returned is NULL

getTimestamp

public java.sql.Timestamp getTimestamp(java.lang.String strColumnName)
Gets the value of the designated column in the current row of this ResultSet object as a Timestamp

Parameters:
strColumnName - column name
Returns:
the column value; if the value is SQL NULL, the value returned is NULL

getDouble

public double getDouble(java.lang.String strColumnName)
Gets the value of the designated column in the current row of this ResultSet object as a double

Parameters:
strColumnName - column name
Returns:
the column value; if the value is SQL NULL, the value returned is NULL

getDouble

public double getDouble(int nIndex)
Gets the value of the designated column in the current row of this ResultSet object as a double

Parameters:
nIndex - the first column is 1, the second is 2, ...
Returns:
the column value; if the value is SQL NULL, the value returned is 0

getObject

public java.lang.Object getObject(int nIndex)
Gets the value of the designated column in the current row of this ResultSet object as a Object

Parameters:
nIndex - the first column is 1, the second is 2, ...
Returns:
the column value; if the value is SQL NULL, the value returned is NULL

getResultSet

public java.sql.ResultSet getResultSet()
Get the ResultSet

Returns:
the resultSet

getObject

public java.lang.Object getObject(java.lang.String strColumnName)
Gets the value of the designated column in the current row of this ResultSet object as an Object

Parameters:
strColumnName - column name
Returns:
the column value; if the value is SQL NULL, the value returned is NULL

next

public boolean next()
Moves the cursor down one row from its current position in the ResultSet.

Returns:
true if the new current row is valid; false if there are no more rows

setIntNull

public void setIntNull(int nIndex)
Fills the prepared statement with a int null value

Parameters:
nIndex - parameter index

finalize

protected void finalize()
                 throws java.lang.Throwable
finalize implementation

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - An exception
See Also:
Object.finalize()


Copyright © 2009 Mairie de Paris. All Rights Reserved.