Class JdbcCacheConnector

java.lang.Object
eu.europa.esig.dss.spi.client.jdbc.JdbcCacheConnector

public class JdbcCacheConnector extends Object
This class executes calls to a javax.sql.DataSource
  • Constructor Details

    • JdbcCacheConnector

      public JdbcCacheConnector(DataSource dataSource)
      Default constructor
      Parameters:
      dataSource - DataSource to connect with
  • Method Details

    • execute

      public int execute(SqlQuery query, Object... arguments)
      This method allows to execute a query with a custom set of arguments, such as SELECT, UPDATE or DELETE, by handling an exception.
      Parameters:
      query - SqlQuery the query
      arguments - an array of Objects, representing the query arguments
      Returns:
      number of rows concerned by the query
    • select

      public Collection<SqlRecord> select(SqlSelectQuery selectQuery, Object... arguments)
      This method executes the query and returns a collection of selected objects
      Parameters:
      selectQuery - SqlSelectQuery the query to SELECT objects
      arguments - an array of Objects, representing the query arguments
      Returns:
      a collection of SqlRecords
    • tableQuery

      public boolean tableQuery(SqlQuery query)
      This method allows table creation, removal and existence check
      Parameters:
      query - SqlQuery the query
      Returns:
      TRUE if the query has been executed successfully, FALSE otherwise
    • executeThrowable

      public int executeThrowable(SqlQuery query) throws SQLException
      This method allows executing of INSERT, UPDATE or DELETE queries, by throwing an exception in case of an error
      Parameters:
      query - SqlQuery the query
      Returns:
      number of concerned rows
      Throws:
      SQLException - if an exception occurs
    • rollback

      protected void rollback(Connection c)
      Rollback transaction for the given Connection
      Parameters:
      c - Connection
    • closeQuietly

      protected void closeQuietly(Connection c, Statement s, ResultSet rs)
      Close the statement and connection and resultset without throwing the exception
      Parameters:
      c - the connection
      s - the statement
      rs - the ResultSet