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

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

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

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 © 2008 Tigase. All Rights Reserved.