igor.vaynberg wrote:
> if you want to use straight jdbc that should be easy. what you need is a
> connection pool - there is one in apache commons.
> 
> you store the connection pool reference in your Application subclass.
> whether you create it there or pull it out of jndi is up to you.
> 
> then you subclass requestcycle and do something like this - if you want a
> transaction-per-request which is a common pattern for webapps
> 
> 
> class JdbcRequestCycle extends WebRequestCycle {
> 
>   private Connection connection;
> 
>   public Connection getConnection() {
>       if (connection==null) {
>           
> connection=((MyApplication)Application.get()).getConnectionPool().getConnection();
>            // configure connection
>            connection.setAutoCommit(false);
>       }
>       return connection;
>    }
> 
>    public void onEndRequest() {
>          if (connection!=null) {
>             connection.commit();
>             // TODO return the connection to the pool here
>             connection=null;
>          }
you should probably connection.close() here

>     }
> 
>    public void onRuntimeException() {
>           if (connection!=null) {
>                connection.commit();
and connection.rollback() here...

>                // TODO return the connection to the pool here
>                connection=null;
and close()

>            }
>     }
> }


-- 
Leszek Gawron
[EMAIL PROTECTED]

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to