BrokenEvent nanotests

com.brokenevent.nanotests.db
Class ConnectionWrapper

java.lang.Object
  extended by com.brokenevent.nanotests.db.ConnectionWrapper

public class ConnectionWrapper
extends java.lang.Object

Simple SQL connection wrapper for connection pooling.

Author:
BrokenEvent

Constructor Summary
ConnectionWrapper(java.lang.String connectionString, java.lang.String login, java.lang.String password)
          Creates and initializes wrapper with a connection.
 
Method Summary
 void close()
          Closes the statement created by this wrapper and releases the wrapper for further usage.
 java.sql.Statement getStatement()
          Create the SQL statement.
 boolean isBusy()
          Checks if the connection wrapper is busy (in use and not released) now.
 void release()
          Releases the connection wrapper and its SQL connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionWrapper

public ConnectionWrapper(java.lang.String connectionString,
                         java.lang.String login,
                         java.lang.String password)
                  throws java.sql.SQLException
Creates and initializes wrapper with a connection.

Parameters:
connectionString - SQL server connection string
login - DB login
password - DB password
Throws:
java.sql.SQLException - when the DriverManager is failed to open connection
Method Detail

getStatement

public java.sql.Statement getStatement()
                                throws java.sql.SQLException
Create the SQL statement. You should not use statement.close() after all operations done. Use wrapper.close() (close()) instead.

Returns:
SQL statement
Throws:
java.sql.SQLException - when connection is failed to create statement

isBusy

public boolean isBusy()
Checks if the connection wrapper is busy (in use and not released) now.

Returns:
True if connection wrapper is in use now

close

public void close()
           throws java.sql.SQLException
Closes the statement created by this wrapper and releases the wrapper for further usage.

Throws:
java.sql.SQLException - when statement is failed to close

release

public void release()
             throws java.sql.SQLException
Releases the connection wrapper and its SQL connection.

Throws:
java.sql.SQLException - when connection is failed to close

BrokenEvent nanotests