org.deegree.commons.utils
Class JDBCUtils

java.lang.Object
  extended by org.deegree.commons.utils.JDBCUtils

public final class JDBCUtils
extends Object

This class contains static utility methods for working with JDBC.

Version:
$Revision: 30829 $, $Date: 2011-05-16 18:47:27 +0200 (Mon, 16 May 2011) $
Author:
Oliver Tonnhofer, last edited by: $Author: mschneider $

Constructor Summary
JDBCUtils()
           
 
Method Summary
static void close(Connection conn)
          Close the object, suppress all errors/exceptions.
static void close(ResultSet resultSet)
          Close the object, suppress all errors/exceptions.
static void close(ResultSet rs, Statement stmt, Connection conn, org.slf4j.Logger log)
          Tries to close each object from a ResultSet, Statement, Connection triple.
static void close(Statement stmt)
          Close the object, suppress all errors/exceptions.
static String determinePostGISVersion(Connection conn, org.slf4j.Logger log)
           
static ResultSet executeQuery(PreparedStatement stmt, ConnectionManager connManager, String connId, long executionTimeout)
          Executes the SQL query in the given PreparedStatement object and returns the ResultSet object generated by the query.
static String getMessage(SQLException e)
           
static void log(SQLException e, org.slf4j.Logger log)
           
static boolean useLegayPostGISPredicates(Connection conn, org.slf4j.Logger log)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCUtils

public JDBCUtils()
Method Detail

log

public static void log(SQLException e,
                       org.slf4j.Logger log)

getMessage

public static String getMessage(SQLException e)

close

public static void close(Connection conn)
Close the object, suppress all errors/exceptions. Useful for finally clauses.

Parameters:
conn -

close

public static void close(ResultSet resultSet)
Close the object, suppress all errors/exceptions. Useful for finally clauses.

Parameters:
resultSet -

close

public static void close(Statement stmt)
Close the object, suppress all errors/exceptions. Useful for finally clauses.

Parameters:
stmt -

close

public static void close(ResultSet rs,
                         Statement stmt,
                         Connection conn,
                         org.slf4j.Logger log)
Tries to close each object from a ResultSet, Statement, Connection triple. Useful for cleaning up in finally clauses.

Parameters:
rs - ResultSet to be closed
stmt - Statement to be closed
conn - Connection to be closed
log - used to log error messages, may be null

determinePostGISVersion

public static String determinePostGISVersion(Connection conn,
                                             org.slf4j.Logger log)

useLegayPostGISPredicates

public static boolean useLegayPostGISPredicates(Connection conn,
                                                org.slf4j.Logger log)

executeQuery

public static ResultSet executeQuery(PreparedStatement stmt,
                                     ConnectionManager connManager,
                                     String connId,
                                     long executionTimeout)
                              throws SQLException
Executes the SQL query in the given PreparedStatement object and returns the ResultSet object generated by the query.

Parameters:
stmt - statement to be executed, must not be null
connManager - ConnectionManager that has been used to retrieve the connection (needed for invalidating cancelled queries), must not be null
connId - id of the connection pool that the connection belongs to (needed for invalidating cancelled queries), must not be null
executionTimeout - timeout in milliseconds, if 0 or negative, timeout is disabled
Returns:
a ResultSet object that contains the data produced by the query, never null
Throws:
SQLException - if an execution timeout or a database access error occurs; this method is called on a closed PreparedStatement or the SQL statement does not return a ResultSet object


Copyright © 2011. All Rights Reserved.