Discussions

EJB design: How to use connection pooling in struts

  1. How to use connection pooling in struts (1 messages)

    Hello,
    I am using struts and postgres. I have configured my datasource using struct-config.xml file. In database bean for each method i am using
    private void getConnection()
    throws SQLException {
    if (connection == null) {
    connection = dataSource.getConnection();}}
     and do the work and using
    public void closeConnection() {
    try {if (connection != null)
    connection.close();}
    catch(SQLException exception) {//exception}
    connection=null;
    dataSource = null;}
    closing the connection.
    ***********************
     I have 2 questions
    Does this practice create performance problem?
    If yes
    Can someone tell me how to use connection pooling
    Thanks in Advance,
    - Girish
  2. Hello,I am using struts and postgres. I have configured my datasource using struct-config.xml file. In database bean for each method i am using private void getConnection() throws SQLException {if (connection == null) {connection = dataSource.getConnection();}} and do the work and using public void closeConnection() { try {if (connection != null) connection.close();} catch(SQLException exception) {//exception} connection=null; dataSource = null;}closing the connection.*********************** I have 2 questionsDoes this practice create performance problem?If yesCan someone tell me how to use connection poolingThanks in Advance,- Girish

    1)Using a pool definitely boots performance.

    2) Did you specify the type of the DataSource to be that of the "org.apache.commons.dbcp.BasicDataSource"; if you did then the pooling is done for you.

    http://struts.apache.org/faqs/database.html