jp.sf.amateras.mirage.session
Class DBCPSessionImpl

java.lang.Object
  extended by jp.sf.amateras.mirage.session.DBCPSessionImpl
All Implemented Interfaces:
Session

public class DBCPSessionImpl
extends Object
implements Session

The implementation of Session which gets the connection from the DBCP connection pool.

To enable DBCP, you have to make jdbc.properties as follows:

 session.class=jp.sf.amateras.mirage.session.DBCPSessionImpl
 jdbc.driver=com.mysql.jdbc.Driver
 jdbc.url=jdbc:mysql://localhost/test
 jdbc.user=root
 jdbc.password=
 dbcp.max_active=100
 dbcp.min_idle=10
 dbcp.max_wait=5000
 

Author:
Naoki Takezoe

Constructor Summary
DBCPSessionImpl(Properties properties)
          The constructor.
 
Method Summary
 void begin()
          Begins the transaction.
 void commit()
          Commits the transaction.
 SqlManager getSqlManager()
          Returns the instance of SqlManager.
 boolean isRollbackOnly()
          Returns whether the current transaction has been marked as rollback-only or not marked.
 void release()
          Releases this session.
 void rollback()
          Roolbacks the transaction.
 void setRollbackOnly()
          Marks the current transation as rollback-only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBCPSessionImpl

public DBCPSessionImpl(Properties properties)
The constructor.

Parameters:
properties - the Properties object which has a following properties:
  • jdbc.driver - the JDBC driver classname (optional on JDBC 4.0)
  • jdbc.url - the JDBC connection URL
  • jdbc.user - the username
  • jdbc.password - the password
  • dbcp.max_active - max active connections (optional, default value is 100)
  • dbcp.min_idle - minimum idle time (optional, default value is 10)
  • dbcp.max_wait - max wait time (optional, default value is 5000)
  • sql.cache - if true then SqlManager caches parsing result of 2waySQL
Method Detail

begin

public void begin()
Description copied from interface: Session
Begins the transaction.

Specified by:
begin in interface Session

commit

public void commit()
Description copied from interface: Session
Commits the transaction.

Specified by:
commit in interface Session

rollback

public void rollback()
Description copied from interface: Session
Roolbacks the transaction.

Specified by:
rollback in interface Session

release

public void release()
Description copied from interface: Session
Releases this session.

Specified by:
release in interface Session

getSqlManager

public SqlManager getSqlManager()
Description copied from interface: Session
Returns the instance of SqlManager.

Specified by:
getSqlManager in interface Session
Returns:

setRollbackOnly

public void setRollbackOnly()
Description copied from interface: Session
Marks the current transation as rollback-only.

Specified by:
setRollbackOnly in interface Session

isRollbackOnly

public boolean isRollbackOnly()
Description copied from interface: Session
Returns whether the current transaction has been marked as rollback-only or not marked.

Specified by:
isRollbackOnly in interface Session
Returns:
If marked true; otherwise false


Copyright © 2010-2012 Project Amateras. All Rights Reserved.