Package fr.paris.lutece.util.sql
Class DAOUtil
- java.lang.Object
-
- fr.paris.lutece.util.sql.DAOUtil
-
- All Implemented Interfaces:
AutoCloseable
public class DAOUtil extends Object implements AutoCloseable
Prepared statement util class- Since:
- version 1.3
-
-
Field Summary
Fields Modifier and Type Field Description static StringMSG_EXCEPTION_SELECT_ERROR
-
Constructor Summary
Constructors Constructor Description DAOUtil(String sql)Creates a new DAOUtil object.DAOUtil(String sql, boolean logQueries)Creates a new DAOUtil object.DAOUtil(String strSQL, Plugin plugin)Creates a new DAOUtil object.DAOUtil(String strSQL, Plugin plugin, boolean bLogQueries)Creates a new DAOUtil object.DAOUtil(String sql, Integer autoGeneratedKeys)Creates a new DAOUtil object.DAOUtil(String strSQL, Integer autoGeneratedKeys, Plugin plugin)Creates a new DAOUtil object.DAOUtil(String strSQL, Integer autoGeneratedKeys, Plugin plugin, boolean bLogQueries)Creates a new DAOUtil object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBatch()Adds a set of parameters to thisPreparedStatementobject's batch of commands.voidaddBatch(String sql)Adds the given SQL command to the current list of commands for thisStatementobject.voidclearParameters()Clears the current parameter values immediately.voidclose()int[]executeBatch()Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts.voidexecuteQuery()Executes a queryvoidexecuteUpdate()Executes the update request and throws an error if the result is not 1voidfree()Free connectionArraygetArray(int nIndex)Get an Array valueArraygetArray(String strColumnName)Get an Array valueInputStreamgetAsciiString(int nIndex)Get an ascii value streamInputStreamgetAsciiString(String strColumnName)Get an ascii value streamBigDecimalgetBigDecimal(int nIndex)Get a BigDecimal valueBigDecimalgetBigDecimal(String strColumnName)Get a BigDecimal valueInputStreamgetBinaryStream(int nIndex)Gets a binary stream from a resultSetBlobgetBlob(int nIndex)Gets a blob from a resultsetBlobgetBlob(String strColumnName)Gets a blob from a resultsetbooleangetBoolean(int nIndex)Gets the value of the designated column in the current row of this ResultSet object as a BooleanbooleangetBoolean(String strColumnName)Gets the value of the designated column in the current row of this ResultSet object as a BooleanbytegetByte(int nIndex)Gets a byte from a resultsetbytegetByte(String strColumnName)Gets a byte from a resultsetbyte[]getBytes(int nIndex)Gets a byte array from a resultsetbyte[]getBytes(String strColumnName)Gets a byte array from a resultsetReadergetCharacterStream(int nIndex)Get a character stream valueReadergetCharacterStream(String strColumnName)Get a character stream valueClobgetClob(int nIndex)Get a Clob valueClobgetClob(String strColumnName)Get a Clob valueDategetDate(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.DategetDate(int nIndex, Calendar calendar)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.DategetDate(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.DategetDate(String strColumnName, Calendar calendar)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.doublegetDouble(int nIndex)Gets the value of the designated column in the current row of this ResultSet object as a doubledoublegetDouble(String strColumnName)Gets the value of the designated column in the current row of this ResultSet object as a doublefloatgetFloat(int nIndex)Get a float valuefloatgetFloat(String strColumnName)Get a float valueBigDecimalgetGeneratedKeyBigDecimal(int nIndex)Gets the value of the designated column in the current row of this GeneratedKeys ResultSet object as a BigDecimalbytegetGeneratedKeyByte(int nIndex)Gets the value of the designated column in the current row of this GeneratedKeys ResultSet object as a byteintgetGeneratedKeyInt(int nIndex)Gets the value of the designated column in the current row of this GeneratedKeys ResultSet object as a intlonggetGeneratedKeyLong(int nIndex)Gets the value of the designated column in the current row of this GeneratedKeys ResultSet object as a longshortgetGeneratedKeyShort(int nIndex)Gets the value of the designated column in the current row of this GeneratedKeys ResultSet object as a shortResultSetgetGeneratedKeysResultSet()Get the GeneratedKeys ResultSetintgetInt(int nIndex)Gets the value of the designated column in the current row of this ResultSet object as a intintgetInt(String strColumnName)Gets the value of the designated column in the current row of this ResultSet object as a intlonggetLong(int nIndex)Gets the long valuelonggetLong(String strColumnName)Gets the long valueReadergetNCharacterStream(int nIndex)Get a character stream valueReadergetNCharacterStream(String strColumnName)Get a character stream valueNClobgetNClob(int nIndex)Get a NClob valueNClobgetNClob(String strColumnName)Get a Clob valueStringgetNString(int nIndex)Get a String valueStringgetNString(String strColumnName)Get a StringvalueObjectgetObject(int nIndex)Gets the value of the designated column in the current row of this ResultSet object as a Object<T> TgetObject(int nIndex, Class<T> type)Gets the value of the designated column in the current row of this ResultSet object as a TObjectgetObject(int nIndex, Map<String,Class<?>> map)Gets the value of the designated column in the current row of this ResultSet object as a ObjectObjectgetObject(String strColumnName)Gets the value of the designated column in the current row of this ResultSet object as an Object<T> TgetObject(String strColumnName, Class<T> type)Gets the value of the designated column in the current row of this ResultSet object as an ObjectObjectgetObject(String strColumnName, Map<String,Class<?>> map)Gets the value of the designated column in the current row of this ResultSet object as an ObjectRefgetRef(int nIndex)Get a Ref valueRefgetRef(String strColumnName)Get a Ref valueResultSetgetResultSet()Get the ResultSetRowIdgetRowId(int nIndex)Get a RowId valueRowIdgetRowId(String strColumnName)Get a RowId valueshortgetShort(int nIndex)Get a short valueshortgetShort(String strColumnName)Get a short valueSQLXMLgetSQLXML(int nIndex)Get a SQLXML valueSQLXMLgetSQLXML(String strColumnName)Get a SQLXML valueStringgetString(int nIndex)Gets the value of the designated column in the current row of this ResultSet object as a stringStringgetString(String strColumnName)Gets the value of the designated column in the current row of this ResultSet object as a stringTimegetTime(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.TimegetTime(int nIndex, Calendar calendar)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.TimegetTime(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.TimegetTime(String strColumnName, Calendar calendar)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.TimestampgetTimestamp(int nIndex)Gets the value of the designated column in the current row of this ResultSet object as a timestampTimestampgetTimestamp(int nIndex, Calendar calendar)Gets the value of the designated column in the current row of this ResultSet object as a timestampTimestampgetTimestamp(String strColumnName)Gets the value of the designated column in the current row of this ResultSet object as a TimestampTimestampgetTimestamp(String strColumnName, Calendar calendar)Gets the value of the designated column in the current row of this ResultSet object as a TimestampURLgetURL(int nIndex)Get a URL valueURLgetURL(String strColumnName)Get a URL valuebooleanisLast()Indicates whether the cursor is on the last row of this ResultSet object.booleannext()Moves the cursor down one row from its current position in the ResultSet.booleannextGeneratedKey()Moves the cursor down one row from its current position in the GeneratedKeys ResultSet.voidsetArray(int nIndex, String strTypename, Object[] elements)Set an Array valuevoidsetAsciiStream(int nIndex, InputStream stream)Fills the prepared statement with an ascii value streamvoidsetAsciiStream(int nIndex, InputStream stream, int nLength)Fills the prepared statement with an ascii value streamvoidsetAsciiStream(int nIndex, InputStream stream, long lLength)Fills the prepared statement with an ascii value streamvoidsetBigDecimal(int nIndex, BigDecimal value)Fills the prepared Statement with a BigDecimal valuevoidsetBinaryStream(int nIndex, InputStream iStream)Fills the prepared statement with a binary value streamvoidsetBinaryStream(int nIndex, InputStream iStream, int nBlength)Fills the prepared statement with a binary value streamvoidsetBinaryStream(int nIndex, InputStream iStream, long nBlength)Fills the prepared statement with a binary value streamvoidsetBlob(int nIndex, InputStream stream)Fills the prepared statement with a blob value from a streamvoidsetBlob(int nIndex, InputStream stream, long nLength)Fills the prepared statement with a blob value from a streamvoidsetBlob(int nIndex, Blob blob)Fills the prepared statement with a blob valuevoidsetBoolean(int nIndex, boolean bValue)Fills the prepared statement with a Boolean valuevoidsetByte(int nIndex, byte bValue)Fills the prepared statement with a byte valuevoidsetBytes(int nIndex, byte[] tbValue)Fills the prepared statement with a byte array valuevoidsetCharacterStream(int nIndex, Reader stream)Fills the prepared statement with a character streamvoidsetCharacterStream(int nIndex, Reader stream, int nLength)Fills the prepared statement with a character streamvoidsetCharacterStream(int nIndex, Reader stream, long nLength)Fills the prepared statement with a character streamvoidsetClob(int nIndex, Reader stream)Fills the prepared statement with a Clob streamvoidsetClob(int nIndex, Reader stream, long nLength)Fills the prepared statement with a Clob streamvoidsetClob(int nIndex, Clob clob)Fills the prepared statement with a ClobvoidsetClob(int nIndex, NClob clob)Fills the prepared statement with a NClobvoidsetDate(int nIndex, Date date)Fills the prepared statement with a date valuevoidsetDate(int nIndex, Date date, Calendar calendar)Fills the prepared statement with a date valuevoidsetDouble(int nIndex, double dValue)Fills the prepared statement with a double valuevoidsetDoubleNull(int nIndex)Sets null value for a "double" columnvoidsetFloat(int nIndex, float fValue)Fills the prepared statement with a float valuevoidsetInt(int nIndex, int nValue)Fills the prepared statement with a int valuevoidsetIntNull(int nIndex)Fills the prepared statement with a int null valuevoidsetLong(int nIndex, long lValue)Sets a long valuevoidsetLongNull(int nIndex)Sets null value for a "long" columnvoidsetNCharacterStream(int nIndex, Reader stream)Fills the prepared statement with a character stream valuevoidsetNCharacterStream(int nIndex, Reader stream, long nLength)Fills the prepared statement with a character stream valuevoidsetNClob(int nIndex, Reader stream)Fills the prepared statement with a NClob streamvoidsetNClob(int nIndex, Reader stream, long nLength)Fills the prepared statement with a NClob streamvoidsetNString(int nIndex, String strValue)Fills the prepared statement with a String valuevoidsetNull(int nIndex, int nType)Fills the prepared statement with a null valuevoidsetNull(int nIndex, int nType, String strTypeName)Fills the prepared statement with a null valuevoidsetObject(int nIndex, Object value)Fills the prepared statement with an object valuevoidsetObject(int nIndex, Object value, int nType)Fills the prepared statement with an object valuevoidsetObject(int nIndex, Object value, int nType, int nScaleOrLength)Fills the prepared statement with an object valuevoidsetRef(int nIndex, Ref ref)Fills the prepared statement with an Ref valuevoidsetRowId(int nIndex, RowId rowId)Fills the prepared statement with a RowId valuevoidsetShort(int nIndex, short shortValue)Fills the prepared statement with a short valuevoidsetSQLXML(int nIndex, SQLXML value)Fills the prepared statement with a SQLXML valuevoidsetString(int nIndex, String strValue)Fills the prepared statement with a string valuevoidsetTime(int nIndex, Time time)Fills the prepared statement with a time valuevoidsetTime(int nIndex, Time time, Calendar calendar)Fills the prepared statement with a time valuevoidsetTimestamp(int nIndex, Timestamp ts)Fills the prepared statement with a timestamp valuevoidsetTimestamp(int nIndex, Timestamp ts, Calendar calendar)Fills the prepared statement with a timestamp valuevoidsetURL(int nIndex, URL url)Fills the prepared statement with a URL value
-
-
-
Field Detail
-
MSG_EXCEPTION_SELECT_ERROR
public static final String MSG_EXCEPTION_SELECT_ERROR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DAOUtil
public DAOUtil(String sql)
Creates a new DAOUtil object.- Parameters:
sql- Sql Query for prepared Statement
-
DAOUtil
public DAOUtil(String sql, boolean logQueries)
Creates a new DAOUtil object.- Parameters:
sql- Sql Query for prepared Statement
-
DAOUtil
public DAOUtil(String strSQL, Plugin plugin)
Creates a new DAOUtil object.- Parameters:
strSQL- sql query for prepared Statementplugin- The plugin using this database access
-
DAOUtil
public DAOUtil(String strSQL, Plugin plugin, boolean bLogQueries)
Creates a new DAOUtil object.- Parameters:
strSQL- sql query for prepared Statementplugin- The plugin using this database access
-
DAOUtil
public DAOUtil(String sql, Integer autoGeneratedKeys)
Creates a new DAOUtil object.- Parameters:
sql- Sql Query for prepared StatementautoGeneratedKeys- a flag indicating whether auto-generated keys should be returned; For example one ofStatement.RETURN_GENERATED_KEYSorStatement.NO_GENERATED_KEYS. SeePreparedStatement#prepareStatement(String, int)- Since:
- 6.0.0
-
DAOUtil
public DAOUtil(String strSQL, Integer autoGeneratedKeys, Plugin plugin)
Creates a new DAOUtil object.- Parameters:
strSQL- sql query for prepared StatementautoGeneratedKeys- a flag indicating whether auto-generated keys should be returned; For example one ofStatement.RETURN_GENERATED_KEYSorStatement.NO_GENERATED_KEYS. SeePreparedStatement#prepareStatement(String, int)plugin- The plugin using this database access- Since:
- 6.0.0
-
DAOUtil
public DAOUtil(String strSQL, Integer autoGeneratedKeys, Plugin plugin, boolean bLogQueries)
Creates a new DAOUtil object.- Parameters:
bLogQueries-strSQL- sql query for prepared StatementautoGeneratedKeys- a flag indicating whether auto-generated keys should be returned; For example one ofStatement.RETURN_GENERATED_KEYSorStatement.NO_GENERATED_KEYS. SeePreparedStatement#prepareStatement(String, int)plugin- The plugin using this database access- Since:
- 6.0.0
-
-
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 final void free()
Free connection
-
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, Date date)Fills the prepared statement with a date value- Parameters:
nIndex- parameter indexdate- date value
-
setDate
public void setDate(int nIndex, Date date, Calendar calendar)Fills the prepared statement with a date value- Parameters:
nIndex- parameter indexdate- date valuecalendar- the calendar- Since:
- 5.1.1
- See Also:
PreparedStatement.setDate(int, Date, Calendar)
-
setTime
public void setTime(int nIndex, Time time)Fills the prepared statement with a time value- Parameters:
nIndex- parameter indextime- time value
-
setTime
public void setTime(int nIndex, Time time, Calendar calendar)Fills the prepared statement with a time value- Parameters:
nIndex- parameter indextime- time valuecalendar- the calendat- Since:
- 5.1.1
- See Also:
PreparedStatement.setTime(int, Time, Calendar)
-
setBinaryStream
public void setBinaryStream(int nIndex, InputStream iStream, int nBlength)Fills the prepared statement with a binary value stream- Parameters:
nIndex- parameter indexiStream- the java input stream which contains the binary parameter valuenBlength- the number of bytes in the stream
-
setBinaryStream
public void setBinaryStream(int nIndex, InputStream iStream, long nBlength)Fills the prepared statement with a binary value stream- Parameters:
nIndex- parameter indexiStream- the java input stream which contains the binary parameter valuenBlength- the number of bytes in the stream- Since:
- 5.1.1
- See Also:
PreparedStatement.setBinaryStream(int, InputStream, long)
-
setBinaryStream
public void setBinaryStream(int nIndex, InputStream iStream)Fills the prepared statement with a binary value stream- Parameters:
nIndex- parameter indexiStream- the java input stream which contains the binary parameter value- Since:
- 5.1.1
- See Also:
PreparedStatement.setBinaryStream(int, InputStream)
-
getBinaryStream
public InputStream getBinaryStream(int nIndex)
Gets a binary stream from a resultSet- Parameters:
nIndex- column index- Returns:
- InputStream instance
-
getBlob
public Blob getBlob(int nIndex)
Gets a blob from a resultset- Parameters:
nIndex- column index- Returns:
- Blob instance
-
getBlob
public Blob getBlob(String strColumnName)
Gets a blob from a resultset- Parameters:
strColumnName- column name- Returns:
- Blob instance
-
setBlob
public void setBlob(int nIndex, InputStream stream)Fills the prepared statement with a blob value from a stream- Parameters:
nIndex- the indexstream- the value- Since:
- 5.1.1
- See Also:
PreparedStatement.setBlob(int, InputStream)
-
setBlob
public void setBlob(int nIndex, InputStream stream, long nLength)Fills the prepared statement with a blob value from a stream- Parameters:
nIndex- the indexstream- the valuenLength- the number of bytes to read- Since:
- 5.1.1
- See Also:
PreparedStatement.setBlob(int, InputStream, long)
-
setBlob
public void setBlob(int nIndex, Blob blob)Fills the prepared statement with a blob value- Parameters:
nIndex- the indexblob- the value- Since:
- 5.1.1
- See Also:
PreparedStatement.setBlob(int, InputStream)
-
getBytes
public byte[] getBytes(int nIndex)
Gets a byte array from a resultset- Parameters:
nIndex- column index- Returns:
- byte[] instance
-
getBytes
public byte[] getBytes(String strColumnName)
Gets a byte array from a resultset- Parameters:
strColumnName- column name- Returns:
- byte[] instance
-
getByte
public byte getByte(int nIndex)
Gets a byte from a resultset- Parameters:
nIndex- column index- Returns:
- byte instance
- Since:
- 5.1.1
- See Also:
ResultSet.getByte(int)
-
getByte
public byte getByte(String strColumnName)
Gets a byte from a resultset- Parameters:
strColumnName- column name- Returns:
- byte instance
- Since:
- 5.1.1
- See Also:
ResultSet.getByte(int)
-
setInt
public void setInt(int nIndex, int nValue)Fills the prepared statement with a int value- Parameters:
nIndex- parameter index in the prepared statementnValue- 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 statementbValue- Boolean value
-
setByte
public void setByte(int nIndex, byte bValue)Fills the prepared statement with a byte value- Parameters:
nIndex- parameter index in the prepared statementbValue- byte value- Since:
- 5.1.1
- See Also:
PreparedStatement.setByte(int, byte)
-
setBytes
public void setBytes(int nIndex, byte[] tbValue)Fills the prepared statement with a byte array value- Parameters:
nIndex- parameter index in the prepared statementtbValue- byte array value
-
setString
public void setString(int nIndex, String strValue)Fills the prepared statement with a string value- Parameters:
nIndex- parameter index in the prepared statementstrValue- string value
-
setTimestamp
public void setTimestamp(int nIndex, Timestamp ts)Fills the prepared statement with a timestamp value- Parameters:
nIndex- parameter index in the prepared statementts- timestamp value
-
setTimestamp
public void setTimestamp(int nIndex, Timestamp ts, Calendar calendar)Fills the prepared statement with a timestamp value- Parameters:
nIndex- parameter index in the prepared statementts- timestamp valuecalendar- the calendar- Since:
- 5.1.1
- See Also:
PreparedStatement.setTimestamp(int, Timestamp, Calendar)
-
setDouble
public void setDouble(int nIndex, double dValue)Fills the prepared statement with a double value- Parameters:
nIndex- parameter index in the prepared statementdValue- The value
-
setDoubleNull
public void setDoubleNull(int nIndex)
Sets null value for a "double" column- Parameters:
nIndex- the index
-
getDate
public 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 Date getDate(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
-
getDate
public Date getDate(int nIndex, Calendar calendar)
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, ...calendar- the calendar- Returns:
- the column value; if the value is SQL NULL, the value returned is null
- Since:
- 5.1.1
- See Also:
ResultSet.getDate(int, Calendar)
-
getDate
public Date getDate(String strColumnName, Calendar calendar)
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, ...calendar- the calendar- Returns:
- the column value; if the value is SQL NULL, the value returned is null
- Since:
- 5.1.1
- See Also:
ResultSet.getDate(String, Calendar)
-
getTime
public 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 Time getTime(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
-
getTime
public Time getTime(int nIndex, Calendar calendar)
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, ...calendar- the calendar- Returns:
- the column value; if the value is SQL NULL, the value returned is null
- Since:
- 5.1.1
- See Also:
ResultSet.getTime(int, Calendar)
-
getTime
public Time getTime(String strColumnName, Calendar calendar)
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, ...calendar- the calendar- Returns:
- the column value; if the value is SQL NULL, the value returned is null
- Since:
- 5.1.1
- See Also:
ResultSet.getTime(String, Calendar)
-
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(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(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 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 String getString(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 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 Timestamp getTimestamp(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
-
getTimestamp
public Timestamp getTimestamp(int nIndex, Calendar calendar)
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, ...calendar- the calendar- Returns:
- the column value; if the value is SQL NULL, the value returned is NULL
- Since:
- 5.1.1
- See Also:
ResultSet.getTimestamp(int, Calendar)
-
getTimestamp
public Timestamp getTimestamp(String strColumnName, Calendar calendar)
Gets the value of the designated column in the current row of this ResultSet object as a Timestamp- Parameters:
strColumnName- column namecalendar- the calendar- Returns:
- the column value; if the value is SQL NULL, the value returned is NULL
- Since:
- 5.1.1
- See Also:
ResultSet.getTimestamp(String, Calendar)
-
getDouble
public double getDouble(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 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
-
getObject
public <T> T getObject(int nIndex, Class<T> type)Gets the value of the designated column in the current row of this ResultSet object as a T- Type Parameters:
T- the return type- Parameters:
nIndex- the first column is 1, the second is 2, ...type- the type- Returns:
- the column value; if the value is SQL NULL, the value returned is NULL
- Since:
- 5.1.1
- See Also:
ResultSet.getObject(int, Class)
-
getObject
public Object getObject(int nIndex, Map<String,Class<?>> map)
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, ...map- the type map- Returns:
- the column value; if the value is SQL NULL, the value returned is NULL
- Since:
- 5.1.1
- See Also:
ResultSet.getObject(int, java.util.Map)
-
getResultSet
public ResultSet getResultSet()
Get the ResultSet- Returns:
- the resultSet
-
getGeneratedKeysResultSet
public ResultSet getGeneratedKeysResultSet()
Get the GeneratedKeys ResultSet- Returns:
- the GeneratedKeys ResultSet
- Since:
- 6.0.0
-
getObject
public Object getObject(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
-
getObject
public <T> T getObject(String strColumnName, Class<T> type)
Gets the value of the designated column in the current row of this ResultSet object as an Object- Type Parameters:
T- the return type- Parameters:
strColumnName- column nametype- the type- Returns:
- the column value; if the value is SQL NULL, the value returned is NULL
- Since:
- 5.1.1
- See Also:
ResultSet.getObject(String, Class)
-
getObject
public Object getObject(String strColumnName, Map<String,Class<?>> map)
Gets the value of the designated column in the current row of this ResultSet object as an Object- Parameters:
strColumnName- column namemap- type map- Returns:
- the column value; if the value is SQL NULL, the value returned is NULL
- Since:
- 5.1.1
- See Also:
ResultSet.getObject(String, java.util.Map)
-
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
-
nextGeneratedKey
public boolean nextGeneratedKey()
Moves the cursor down one row from its current position in the GeneratedKeys ResultSet.- Returns:
- true if the new current row is valid; false if there are no more rows
- Since:
- 6.0.0
-
getGeneratedKeyByte
public byte getGeneratedKeyByte(int nIndex)
Gets the value of the designated column in the current row of this GeneratedKeys ResultSet object as a byte- 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
- Since:
- 6.0.0
-
getGeneratedKeyShort
public short getGeneratedKeyShort(int nIndex)
Gets the value of the designated column in the current row of this GeneratedKeys ResultSet object as a short- 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
- Since:
- 6.0.0
-
getGeneratedKeyInt
public int getGeneratedKeyInt(int nIndex)
Gets the value of the designated column in the current row of this GeneratedKeys 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
- Since:
- 6.0.0
-
getGeneratedKeyLong
public long getGeneratedKeyLong(int nIndex)
Gets the value of the designated column in the current row of this GeneratedKeys ResultSet object as a long- 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
- Since:
- 6.0.0
-
getGeneratedKeyBigDecimal
public BigDecimal getGeneratedKeyBigDecimal(int nIndex)
Gets the value of the designated column in the current row of this GeneratedKeys ResultSet object as a BigDecimal- 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
- Since:
- 6.0.0
-
setIntNull
public void setIntNull(int nIndex)
Fills the prepared statement with a int null value- Parameters:
nIndex- parameter index
-
setLongNull
public void setLongNull(int nIndex)
Sets null value for a "long" column- Parameters:
nIndex- the index
-
setLong
public void setLong(int nIndex, long lValue)Sets a long value- Parameters:
nIndex- the indexlValue- the value
-
getLong
public long getLong(int nIndex)
Gets the long value- Parameters:
nIndex- the index- Returns:
- the long value
-
getLong
public long getLong(String strColumnName)
Gets the long value- Parameters:
strColumnName- the column name- Returns:
- the long value
-
setArray
public void setArray(int nIndex, String strTypename, Object[] elements)Set an Array value- Parameters:
nIndex- the indexstrTypename- the type SQL nameelements- the array value- Since:
- 5.1.1
- See Also:
Connection.createArrayOf(String, Object[]),PreparedStatement.setArray(int, Array)
-
getArray
public Array getArray(int nIndex)
Get an Array value- Parameters:
nIndex- the index- Returns:
- the array value
- Since:
- 5.1.1
- See Also:
ResultSet.getArray(int)
-
getArray
public Array getArray(String strColumnName)
Get an Array value- Parameters:
strColumnName- the column name- Returns:
- the array value
- Since:
- 5.1.1
- See Also:
ResultSet.getArray(String)
-
setAsciiStream
public void setAsciiStream(int nIndex, InputStream stream)Fills the prepared statement with an ascii value stream- Parameters:
nIndex- the indexstream- the stream- Since:
- 5.1.1
- See Also:
PreparedStatement.setAsciiStream(int, InputStream)
-
setAsciiStream
public void setAsciiStream(int nIndex, InputStream stream, int nLength)Fills the prepared statement with an ascii value stream- Parameters:
nIndex- the indexstream- the streamnLength- the number of bytes to read- Since:
- 5.1.1
- See Also:
PreparedStatement.setAsciiStream(int, InputStream, int)
-
setAsciiStream
public void setAsciiStream(int nIndex, InputStream stream, long lLength)Fills the prepared statement with an ascii value stream- Parameters:
nIndex- the indexstream- the streamlLength- the number of bytes to read- Since:
- 5.1.1
- See Also:
PreparedStatement.setAsciiStream(int, InputStream, long)
-
getAsciiString
public InputStream getAsciiString(int nIndex)
Get an ascii value stream- Parameters:
nIndex- the index- Returns:
- the ascii stream
- Since:
- 5.1.1
- See Also:
ResultSet.getAsciiStream(int)
-
getAsciiString
public InputStream getAsciiString(String strColumnName)
Get an ascii value stream- Parameters:
strColumnName- the column name- Returns:
- the ascii stream
- Since:
- 5.1.1
- See Also:
ResultSet.getAsciiStream(String)
-
setBigDecimal
public void setBigDecimal(int nIndex, BigDecimal value)Fills the prepared Statement with a BigDecimal value- Parameters:
nIndex- the indexvalue- the value- Since:
- 5.1.1
- See Also:
PreparedStatement.setBigDecimal(int, BigDecimal)
-
getBigDecimal
public BigDecimal getBigDecimal(int nIndex)
Get a BigDecimal value- Parameters:
nIndex- the index- Returns:
- the value
- Since:
- 5.1.1
- See Also:
ResultSet.getBigDecimal(int)
-
getBigDecimal
public BigDecimal getBigDecimal(String strColumnName)
Get a BigDecimal value- Parameters:
strColumnName- the column name- Returns:
- the value
- Since:
- 5.1.1
- See Also:
ResultSet.getBigDecimal(String)
-
setCharacterStream
public void setCharacterStream(int nIndex, Reader stream)Fills the prepared statement with a character stream- Parameters:
nIndex- the indexstream- the stream- Since:
- 5.1.1
- See Also:
PreparedStatement.setCharacterStream(int, Reader)
-
setCharacterStream
public void setCharacterStream(int nIndex, Reader stream, int nLength)Fills the prepared statement with a character stream- Parameters:
nIndex- the indexstream- the streamnLength- the number of bytes to read- Since:
- 5.1.1
- See Also:
PreparedStatement.setCharacterStream(int, Reader, int)
-
setCharacterStream
public void setCharacterStream(int nIndex, Reader stream, long nLength)Fills the prepared statement with a character stream- Parameters:
nIndex- the indexstream- the streamnLength- the number of bytes to read- Since:
- 5.1.1
- See Also:
PreparedStatement.setCharacterStream(int, Reader, long)
-
getCharacterStream
public Reader getCharacterStream(int nIndex)
Get a character stream value- Parameters:
nIndex- the column index- Returns:
- the stream value
- Since:
- 5.1.1
- See Also:
ResultSet.getCharacterStream(int)
-
getCharacterStream
public Reader getCharacterStream(String strColumnName)
Get a character stream value- Parameters:
strColumnName- the column index- Returns:
- the stream value
- Since:
- 5.1.1
- See Also:
ResultSet.getCharacterStream(String)
-
setClob
public void setClob(int nIndex, Reader stream)Fills the prepared statement with a Clob stream- Parameters:
nIndex- the indexstream- the value- Since:
- 5.1.1
- See Also:
PreparedStatement.setClob(int, Reader)
-
setClob
public void setClob(int nIndex, Reader stream, long nLength)Fills the prepared statement with a Clob stream- Parameters:
nIndex- the indexstream- the valuenLength- the number of bytes to read- Since:
- 5.1.1
- See Also:
PreparedStatement.setClob(int, Reader, long)
-
setClob
public void setClob(int nIndex, Clob clob)Fills the prepared statement with a Clob- Parameters:
nIndex- the indexclob- the value- Since:
- 5.1.1
- See Also:
PreparedStatement.setClob(int, Clob)
-
getClob
public Clob getClob(int nIndex)
Get a Clob value- Parameters:
nIndex- the column index- Returns:
- the value
- Since:
- 5.1.1
- See Also:
ResultSet.getClob(int)
-
getClob
public Clob getClob(String strColumnName)
Get a Clob value- Parameters:
strColumnName- the column index- Returns:
- the value
- Since:
- 5.1.1
- See Also:
ResultSet.getClob(String)
-
setNClob
public void setNClob(int nIndex, Reader stream)Fills the prepared statement with a NClob stream- Parameters:
nIndex- the indexstream- the value- Since:
- 5.1.1
- See Also:
PreparedStatement.setNClob(int, Reader)
-
setNClob
public void setNClob(int nIndex, Reader stream, long nLength)Fills the prepared statement with a NClob stream- Parameters:
nIndex- the indexstream- the valuenLength- the number of bytes to read- Since:
- 5.1.1
- See Also:
PreparedStatement.setNClob(int, Reader, long)
-
setClob
public void setClob(int nIndex, NClob clob)Fills the prepared statement with a NClob- Parameters:
nIndex- the indexclob- the value- Since:
- 5.1.1
- See Also:
PreparedStatement.setNClob(int, NClob)
-
getNClob
public NClob getNClob(int nIndex)
Get a NClob value- Parameters:
nIndex- the column index- Returns:
- the value
- Since:
- 5.1.1
- See Also:
ResultSet.getNClob(int)
-
getNClob
public NClob getNClob(String strColumnName)
Get a Clob value- Parameters:
strColumnName- the column index- Returns:
- the value
- Since:
- 5.1.1
- See Also:
ResultSet.getClob(String)
-
setFloat
public void setFloat(int nIndex, float fValue)Fills the prepared statement with a float value- Parameters:
nIndex- the indexfValue- the value- Since:
- 5.1.1
- See Also:
PreparedStatement.setFloat(int, float)
-
getFloat
public float getFloat(String strColumnName)
Get a float value- Parameters:
strColumnName- the column name- Returns:
- the value
- Since:
- 5.1.1
- See Also:
ResultSet.getFloat(String)
-
getFloat
public float getFloat(int nIndex)
Get a float value- Parameters:
nIndex- the column index- Returns:
- the value
- Since:
- 5.1.1
- See Also:
ResultSet.getFloat(int)
-
setNCharacterStream
public void setNCharacterStream(int nIndex, Reader stream)Fills the prepared statement with a character stream value- Parameters:
nIndex- the indexstream- the stream- Since:
- 5.1.1
- See Also:
PreparedStatement.setNCharacterStream(int, Reader)
-
setNCharacterStream
public void setNCharacterStream(int nIndex, Reader stream, long nLength)Fills the prepared statement with a character stream value- Parameters:
nIndex- the indexstream- the streamnLength- the number of characters to read- Since:
- 5.1.1
- See Also:
PreparedStatement.setNCharacterStream(int, Reader, long)
-
getNCharacterStream
public Reader getNCharacterStream(int nIndex)
Get a character stream value- Parameters:
nIndex- the index- Returns:
- the stream
- Since:
- 5.1.1
- See Also:
ResultSet.getNCharacterStream(int)
-
getNCharacterStream
public Reader getNCharacterStream(String strColumnName)
Get a character stream value- Parameters:
strColumnName- the column name- Returns:
- the stream
- Since:
- 5.1.1
- See Also:
ResultSet.getNCharacterStream(String)
-
setNString
public void setNString(int nIndex, String strValue)Fills the prepared statement with a String value- Parameters:
nIndex- the indexstrValue- the value- Since:
- 5.1.1
- See Also:
PreparedStatement.setNString(int, String)
-
getNString
public String getNString(int nIndex)
Get a String value- Parameters:
nIndex- the index- Returns:
- the String
- Since:
- 5.1.1
- See Also:
ResultSet.getNString(int)
-
getNString
public String getNString(String strColumnName)
Get a Stringvalue- Parameters:
strColumnName- the column name- Returns:
- the stream
- Since:
- 5.1.1
- See Also:
ResultSet.getNString(String)
-
setNull
public void setNull(int nIndex, int nType)Fills the prepared statement with a null value- Parameters:
nIndex- the indexnType- the SQL type code defined in java.sql.Types- Since:
- 5.1.1
- See Also:
PreparedStatement.setNull(int, int)
-
setNull
public void setNull(int nIndex, int nType, String strTypeName)Fills the prepared statement with a null value- Parameters:
nIndex- the indexnType- the SQL type code defined in java.sql.TypesstrTypeName- the type name- Since:
- 5.1.1
- See Also:
PreparedStatement.setNull(int, int, String)
-
setObject
public void setObject(int nIndex, Object value)Fills the prepared statement with an object value- Parameters:
nIndex- the indexvalue- the value- Since:
- 5.1.1
- See Also:
PreparedStatement.setObject(int, Object)
-
setObject
public void setObject(int nIndex, Object value, int nType)Fills the prepared statement with an object value- Parameters:
nIndex- the indexvalue- the valuenType- the target SQL type (as defined in java.sql.Types)- Since:
- 5.1.1
- See Also:
PreparedStatement.setObject(int, Object, int)
-
setObject
public void setObject(int nIndex, Object value, int nType, int nScaleOrLength)Fills the prepared statement with an object value- Parameters:
nIndex- the indexvalue- the valuenType- the target SQL type (as defined in java.sql.Types)nScaleOrLength- the scale or length- Since:
- 5.1.1
- See Also:
PreparedStatement.setObject(int, Object, int, int)
-
getRef
public Ref getRef(int nIndex)
Get a Ref value- Parameters:
nIndex- the index- Returns:
- the ref
- Since:
- 5.1.1
- See Also:
ResultSet.getRef(int)
-
getRef
public Ref getRef(String strColumnName)
Get a Ref value- Parameters:
strColumnName- the column name- Returns:
- the ref
- Since:
- 5.1.1
- See Also:
ResultSet.getRef(String)
-
setRef
public void setRef(int nIndex, Ref ref)Fills the prepared statement with an Ref value- Parameters:
nIndex- the indexref- the Ref- Since:
- 5.1.1
- See Also:
PreparedStatement.setRef(int, Ref)
-
setRowId
public void setRowId(int nIndex, RowId rowId)Fills the prepared statement with a RowId value- Parameters:
nIndex- the indexrowId- the value- Since:
- 5.1.1
- See Also:
PreparedStatement.setRowId(int, RowId)
-
getRowId
public RowId getRowId(int nIndex)
Get a RowId value- Parameters:
nIndex- the index- Returns:
- the rowId
- Since:
- 5.1.1
- See Also:
ResultSet.getRowId(int)
-
getRowId
public RowId getRowId(String strColumnName)
Get a RowId value- Parameters:
strColumnName- the column name- Returns:
- the rowId
- Since:
- 5.1.1
- See Also:
ResultSet.getRowId(String)
-
setShort
public void setShort(int nIndex, short shortValue)Fills the prepared statement with a short value- Parameters:
nIndex- the indexshortValue- the value- Since:
- 5.1.1
- See Also:
PreparedStatement.setShort(int, short)
-
getShort
public short getShort(String strColumnName)
Get a short value- Parameters:
strColumnName- the column name- Returns:
- the value
- Since:
- 5.1.1
- See Also:
ResultSet.getShort(String)
-
getShort
public short getShort(int nIndex)
Get a short value- Parameters:
nIndex- the column index- Returns:
- the value
- Since:
- 5.1.1
- See Also:
ResultSet.getShort(int)
-
setSQLXML
public void setSQLXML(int nIndex, SQLXML value)Fills the prepared statement with a SQLXML value- Parameters:
nIndex- the indexvalue- the value- Since:
- 5.1.1
- See Also:
PreparedStatement.setSQLXML(int, SQLXML)
-
getSQLXML
public SQLXML getSQLXML(String strColumnName)
Get a SQLXML value- Parameters:
strColumnName- the column name- Returns:
- the value
- Since:
- 5.1.1
- See Also:
ResultSet.getSQLXML(String)
-
getSQLXML
public SQLXML getSQLXML(int nIndex)
Get a SQLXML value- Parameters:
nIndex- the column index- Returns:
- the value
- Since:
- 5.1.1
- See Also:
ResultSet.getSQLXML(int)
-
setURL
public void setURL(int nIndex, URL url)Fills the prepared statement with a URL value- Parameters:
nIndex- the indexurl- the URL- Since:
- 5.1.1
- See Also:
PreparedStatement.setURL(int, URL)
-
getURL
public URL getURL(String strColumnName)
Get a URL value- Parameters:
strColumnName- the column name- Returns:
- the value
- Since:
- 5.1.1
- See Also:
ResultSet.getURL(String)
-
getURL
public URL getURL(int nIndex)
Get a URL value- Parameters:
nIndex- the column index- Returns:
- the value
- Since:
- 5.1.1
- See Also:
ResultSet.getURL(int)
-
addBatch
public void addBatch()
Adds a set of parameters to thisPreparedStatementobject's batch of commands.- Since:
- 7.0.0
-
addBatch
public void addBatch(String sql)
Adds the given SQL command to the current list of commands for thisStatementobject. The commands in this list can be executed as a batch by calling the methodexecuteBatch.Note:This method cannot be called on a
PreparedStatementorCallableStatement.- Parameters:
sql- typically this is a SQLINSERTorUPDATEstatement this method is called on a closedStatement, the driver does not support batch updates, the method is called on aPreparedStatementorCallableStatement- Since:
- 7.0.0
- See Also:
executeBatch(),DatabaseMetaData#supportsBatchUpdates
-
clearParameters
public void clearParameters()
Clears the current parameter values immediately.In general, parameter values remain in force for repeated use of a statement. Setting a parameter value automatically clears its previous value. However, in some cases it is useful to immediately release the resources used by the current parameter values; this can be done by calling the method
clearParameters.- Since:
- 7.0.0
-
executeBatch
public int[] executeBatch()
Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts.- Returns:
- The elements of the array that is returned are ordered to correspond to the commands in the batch, which are ordered according to the order in which they were added to the batch.
- Since:
- 7.0.0
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
-