de.uplanet.lucy.server.util.db
Class DbQuery

java.lang.Object
  extended by de.uplanet.lucy.server.util.db.DbQuery
All Implemented Interfaces:
de.uplanet.util.ICloseable

public final class DbQuery
extends java.lang.Object
implements de.uplanet.util.ICloseable

Version:
$Revision: 81036 $

Constructor Summary
DbQuery()
           
 
Method Summary
 void close()
          Close this database query object and all dependent DbPreparedStatement and DbResultSet objects.
 java.lang.Object executeAndGetScalarValue(de.uplanet.jdbc.JdbcConnection p_conn, java.lang.String p_strQuery)
          Get the value of the first column in the first row of the result set.
 java.lang.Object executeAndGetScalarValue(de.uplanet.jdbc.JdbcConnection p_conn, java.lang.String p_strQuery, groovy.lang.Closure p_closure)
          Get the value of the first column in the first row of the result set.
 java.lang.Object executeAndGetScalarValue(de.uplanet.jdbc.JdbcConnection p_conn, java.lang.String p_strQuery, java.lang.Object p_valueFallback)
          Get the value of the first column in the first row of the result set.
 java.lang.Object executeAndGetScalarValue(de.uplanet.jdbc.JdbcConnection p_conn, java.lang.String p_strQuery, java.lang.Object p_valueFallback, groovy.lang.Closure p_closure)
          Get the value of the first column in the first row of the result set.
 IValueHolder<?> executeAndGetScalarValueHolder(de.uplanet.jdbc.JdbcConnection p_conn, java.lang.String p_strQuery)
          Get the value of the first column in the first row of the result set.
 int executeUpdate(de.uplanet.jdbc.JdbcConnection p_conn, java.lang.String p_strQuery)
          Execute a prepared INSERT or UPDATE statement.
 int executeUpdate(de.uplanet.jdbc.JdbcConnection p_conn, java.lang.String p_strQuery, groovy.lang.Closure p_closure)
          Execute a prepared INSERT or UPDATE statement.
 DbPreparedStatement prepare(de.uplanet.jdbc.JdbcConnection p_conn, java.lang.String p_strQuery)
          Prepares a statement.
 DbPreparedStatement prepareDeprecated(de.uplanet.jdbc.JdbcConnection p_conn, java.lang.String p_strQuery)
          Deprecated.  
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbQuery

public DbQuery()
Method Detail

executeAndGetScalarValueHolder

public IValueHolder<?> executeAndGetScalarValueHolder(de.uplanet.jdbc.JdbcConnection p_conn,
                                                      java.lang.String p_strQuery)
                                               throws java.sql.SQLException
Get the value of the first column in the first row of the result set.

If the result set is empty, null is returned.

Returns:
A value holder that contains the value of the first column in the first row of the result set, or null if the result set is empty.
Throws:
java.sql.SQLException

executeAndGetScalarValue

public java.lang.Object executeAndGetScalarValue(de.uplanet.jdbc.JdbcConnection p_conn,
                                                 java.lang.String p_strQuery,
                                                 java.lang.Object p_valueFallback)
                                          throws java.sql.SQLException
Get the value of the first column in the first row of the result set.

If the result set is empty, or the value is null, p_valueIfNull is returned.

Parameters:
p_conn - The database connection to be used.
p_strQuery - The query.
p_valueFallback - The return value if the query returns an empty result set, or null.
Returns:
The value of the first column in the first row of the result set, or p_valueIfNull if the result set is empty, or the value is null.
Throws:
java.sql.SQLException

executeAndGetScalarValue

public java.lang.Object executeAndGetScalarValue(de.uplanet.jdbc.JdbcConnection p_conn,
                                                 java.lang.String p_strQuery)
                                          throws java.sql.SQLException
Get the value of the first column in the first row of the result set.

If the result set is empty, null is returned.

Returns:
The value of the first column in the first row of the result set, or null if the result set is empty.
Throws:
java.sql.SQLException

executeAndGetScalarValue

public java.lang.Object executeAndGetScalarValue(de.uplanet.jdbc.JdbcConnection p_conn,
                                                 java.lang.String p_strQuery,
                                                 java.lang.Object p_valueFallback,
                                                 groovy.lang.Closure p_closure)
                                          throws java.sql.SQLException
Get the value of the first column in the first row of the result set.

If the result set is empty or the value is null, p_valueIfNull is returned.

Parameters:
p_conn - The database connection to be used.
p_strQuery - The query.
p_valueFallback - The return value if the query returns an empty result set, or null.
p_closure - The closure that prepares the statement.
Returns:
The value of the first column in the first row of the result set, or p_valueIfNull if the result set is empty or the value is null.
Throws:
java.sql.SQLException

executeAndGetScalarValue

public java.lang.Object executeAndGetScalarValue(de.uplanet.jdbc.JdbcConnection p_conn,
                                                 java.lang.String p_strQuery,
                                                 groovy.lang.Closure p_closure)
                                          throws java.sql.SQLException
Get the value of the first column in the first row of the result set.

If the result set is empty or the value is null, p_valueIfNull is returned.

Parameters:
p_conn - The database connection to be used.
p_strQuery - The query.
p_closure - The closure that prepares the statement.
Returns:
The value of the first column in the first row of the result set, or p_valueIfNull if the result set is empty or the value is null.
Throws:
java.sql.SQLException

executeUpdate

public int executeUpdate(de.uplanet.jdbc.JdbcConnection p_conn,
                         java.lang.String p_strQuery)
                  throws java.sql.SQLException
Execute a prepared INSERT or UPDATE statement.

Parameters:
p_conn - The database connection to be used.
p_strQuery - The SQL statement to be executed.
Returns:
The number of affected rows in the database, or 0.
Throws:
java.sql.SQLException

executeUpdate

public int executeUpdate(de.uplanet.jdbc.JdbcConnection p_conn,
                         java.lang.String p_strQuery,
                         groovy.lang.Closure p_closure)
                  throws java.sql.SQLException
Execute a prepared INSERT or UPDATE statement.

Parameters:
p_conn - The database connection to be used.
p_strQuery - The (prepared) SQL statement to be executed.
p_closure - The closure that prepares the statement.
Returns:
The number of affected rows in the database, or 0.
Throws:
java.sql.SQLException

prepare

public DbPreparedStatement prepare(de.uplanet.jdbc.JdbcConnection p_conn,
                                   java.lang.String p_strQuery)
                            throws java.sql.SQLException
Prepares a statement.

Parameters:
p_conn - The database connection to be used.
p_strQuery - The (parameterized) SQL query.
Returns:
A prepared statement object.
Throws:
java.sql.SQLException - If a database error occurred.

prepareDeprecated

@Deprecated
public DbPreparedStatement prepareDeprecated(de.uplanet.jdbc.JdbcConnection p_conn,
                                                        java.lang.String p_strQuery)
                                      throws java.sql.SQLException
Deprecated. 

In deprecated mode DbDisconnectedRow does not support null values for primitive numeric or boolean datatypes, but returns 0 or false values instead.

Throws:
java.sql.SQLException

close

public void close()
           throws java.sql.SQLException
Close this database query object and all dependent DbPreparedStatement and DbResultSet objects.

Specified by:
close in interface de.uplanet.util.ICloseable
Throws:
java.sql.SQLException - If a database error occurred.


Last updated: 2011-01-27
Copyright 2000-2010 United Planet. All Rights Reserved.