tigase.util
Class JDBCAbstract

java.lang.Object
  extended by tigase.util.JDBCAbstract

public abstract class JDBCAbstract
extends java.lang.Object

Describe class JDBCAbstract here. Created: Mon Mar 3 10:43:44 2008

Version:
$Rev$
Author:
Artur Hefczyc

Field Summary
static java.lang.String DERBY_CONNVALID_QUERY
          Field description
static java.lang.String JDBC_CONNVALID_QUERY
          Field description
static java.lang.String SP_STARTS_WITH
          Field description
 
Constructor Summary
JDBCAbstract()
           
 
Method Summary
protected  boolean checkConnection()
          checkConnection method checks database connection before any query.
 java.lang.String getResourceUri()
          getResourceUri method returns database connection string.
protected  void initPreparedStatements()
          initPreparedStatements method initializes internal database connection variables such as prepared statements.
abstract  void initRepository(java.lang.String conn_str, java.util.Map<java.lang.String,java.lang.String> params)
          initRepository method is doing lazy initialization with database.
 java.sql.CallableStatement prepareCallable(java.lang.String query)
          Method description
 java.sql.PreparedStatement prepareQuery(java.lang.String query)
          Method description
 java.sql.PreparedStatement prepareStatement(java.lang.String query)
          Method description
protected  void release(java.sql.Statement stmt, java.sql.ResultSet rs)
           
 void setResourceUri(java.lang.String uri)
          Method description
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SP_STARTS_WITH

public static final java.lang.String SP_STARTS_WITH
Field description

See Also:
Constant Field Values

DERBY_CONNVALID_QUERY

public static final java.lang.String DERBY_CONNVALID_QUERY
Field description

See Also:
Constant Field Values

JDBC_CONNVALID_QUERY

public static final java.lang.String JDBC_CONNVALID_QUERY
Field description

See Also:
Constant Field Values
Constructor Detail

JDBCAbstract

public JDBCAbstract()
Method Detail

initRepository

public abstract void initRepository(java.lang.String conn_str,
                                    java.util.Map<java.lang.String,java.lang.String> params)
                             throws java.sql.SQLException
initRepository method is doing lazy initialization with database. Connection to database will be established during the first authentication request.

Parameters:
conn_str - a String value of database connection string. The string must also contain database user name and password if required for connection.
params -
Throws:
java.sql.SQLException - if an error occurs during access database. It won't happen however as in this method we do simple variable assigment.

getResourceUri

public java.lang.String getResourceUri()
getResourceUri method returns database connection string.

Returns:
a String value of database connection string.

prepareCallable

public java.sql.CallableStatement prepareCallable(java.lang.String query)
                                           throws java.sql.SQLException
Method description

Parameters:
query -
Returns:
Throws:
java.sql.SQLException

prepareQuery

public java.sql.PreparedStatement prepareQuery(java.lang.String query)
                                        throws java.sql.SQLException
Method description

Parameters:
query -
Returns:
Throws:
java.sql.SQLException

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String query)
                                            throws java.sql.SQLException
Method description

Parameters:
query -
Returns:
Throws:
java.sql.SQLException

setResourceUri

public void setResourceUri(java.lang.String uri)
Method description

Parameters:
uri -

checkConnection

protected boolean checkConnection()
                           throws java.sql.SQLException
checkConnection method checks database connection before any query. For some database servers (or JDBC drivers) it happens the connection is dropped if not in use for a long time or after certain timeout passes. This method allows us to detect the problem and reinitialize database connection.

Returns:
a boolean value if the database connection is working.
Throws:
java.sql.SQLException - if an error occurs on database query.

initPreparedStatements

protected void initPreparedStatements()
                               throws java.sql.SQLException
initPreparedStatements method initializes internal database connection variables such as prepared statements.

Throws:
java.sql.SQLException - if an error occurs on database query.

release

protected void release(java.sql.Statement stmt,
                       java.sql.ResultSet rs)


Copyright © 2001-2006 Tigase Developers Team. All rights Reserved.