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: 552 $
Author:
Artur Hefczyc

Field Summary
static java.lang.String DERBY_CONNVALID_QUERY
           
static java.lang.String JDBC_CONNVALID_QUERY
           
 
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)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String query)
           
protected  void release(java.sql.Statement stmt, java.sql.ResultSet rs)
           
 void setResourceUri(java.lang.String uri)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DERBY_CONNVALID_QUERY

public static final java.lang.String DERBY_CONNVALID_QUERY
See Also:
Constant Field Values

JDBC_CONNVALID_QUERY

public static final java.lang.String JDBC_CONNVALID_QUERY
See Also:
Constant Field Values
Constructor Detail

JDBCAbstract

public JDBCAbstract()
Method Detail

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.

release

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

getResourceUri

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

Returns:
a String value of database connection string.

setResourceUri

public void setResourceUri(java.lang.String uri)

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String query)
                                            throws java.sql.SQLException
Throws:
java.sql.SQLException

prepareCallable

public java.sql.CallableStatement prepareCallable(java.lang.String query)
                                           throws java.sql.SQLException
Throws:
java.sql.SQLException

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.

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.
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.


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