com.mysql.management.util
Class QueryUtil

java.lang.Object
  extended by com.mysql.management.util.QueryUtil

public class QueryUtil
extends java.lang.Object


Constructor Summary
QueryUtil(java.sql.Connection conn)
           
QueryUtil(java.sql.Connection conn, java.io.PrintStream err)
           
 
Method Summary
 boolean execute(java.lang.String query)
           
 boolean execute(java.lang.String query, java.lang.Object[] params)
           
 int[] executeBatch(java.lang.String query, java.lang.Object[][] params)
           
 java.util.List executeQuery(java.lang.String query)
           
 java.util.List executeQuery(java.lang.String query, java.lang.Object[] params)
           
 int executeUpdate(java.lang.String query)
           
 int executeUpdate(java.lang.String query, java.lang.Object[] params)
           
 java.util.List executeUpdateReturningKeys(java.lang.String query)
           
 java.util.List executeUpdateReturningKeys(java.lang.String query, java.lang.Object[] params)
           
 java.lang.String queryForString(java.lang.String query)
           
 java.lang.String queryForString(java.lang.String query, java.lang.Object[] params)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryUtil

public QueryUtil(java.sql.Connection conn)

QueryUtil

public QueryUtil(java.sql.Connection conn,
                 java.io.PrintStream err)
Method Detail

executeQuery

public java.util.List executeQuery(java.lang.String query,
                                   java.lang.Object[] params)
Parameters:
query - the SQL Query to execute
params - the Object[] containing the variables for the query
Returns:
a java.util.List of Maps. Each Row of the query result set is represented by a map in the list. Each map in the list has an Map.Entry of column name to column value.

executeQuery

public java.util.List executeQuery(java.lang.String query)
Parameters:
query - the SQL Query to execute
Returns:
a java.util.List of Maps. Each Row of the query result set is represented by a map in the list. Each map in the list has an Map.Entry of column name to column value.

executeUpdate

public int executeUpdate(java.lang.String query,
                         java.lang.Object[] params)
Parameters:
query - the SQL Query to execute
params - the Object[] containing the parameters for the query
Returns:
the row count (or 0 for SQL statements which return nothing)

execute

public boolean execute(java.lang.String query,
                       java.lang.Object[] params)
Parameters:
query - the SQL Query to execute
params - the Object[] containing the parameters for the query
Returns:
true if the next result is a ResultSet; false if it is an update count or there are no more results

executeBatch

public int[] executeBatch(java.lang.String query,
                          java.lang.Object[][] params)
Parameters:
query - the SQL Query to execute
params - the Object[][] containing the parameters for the query for each item in the batch
Returns:
an array of update counts containing one element for each command in the batch. The array is ordered according to the order in which commands were inserted into the batch

executeUpdate

public int executeUpdate(java.lang.String query)
Parameters:
query - the SQL Query to execute
params - the Object[] containing the parameters for the query
Returns:
either a row count, or 0 for SQL commands

execute

public boolean execute(java.lang.String query)
Parameters:
query - the SQL Query to execute
Returns:
true if the next result is a ResulSet, false if it is an update count or there are no more results

executeUpdateReturningKeys

public java.util.List executeUpdateReturningKeys(java.lang.String query)
Parameters:
query - the SQL Query to execute
Returns:
a java.util.List of Maps. Each Row of the query result set is represented by a map in the list. Each map in the list has an Map.Entry of column name (GENERATED_KEY) to column value (the key generated).

executeUpdateReturningKeys

public java.util.List executeUpdateReturningKeys(java.lang.String query,
                                                 java.lang.Object[] params)
Parameters:
query - the SQL Query to execute
params - the Object[] containing the variables for the query
Returns:
a java.util.List of Maps. Each Row of the query result set is represented by a map in the list. Each map in the list has an Map.Entry of column name (GENERATED_KEY) to column value (the key generated).

queryForString

public java.lang.String queryForString(java.lang.String query)
Parameters:
query - the SQL Query to execute
Returns:
first column value of the first row returned, or null

queryForString

public java.lang.String queryForString(java.lang.String query,
                                       java.lang.Object[] params)
Parameters:
query - the SQL Query to execute
params - the Object[] containing the parameters for the query
Returns:
either null or the first row's first column value.toString()


Copyright © 2004-2011. All Rights Reserved.