You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by "Francis De Brabandere (JIRA)" <em...@incubator.apache.org> on 2013/09/01 22:22:51 UTC

[jira] [Commented] (EMPIREDB-191) The spring example not release connection cause connection pool exhausted.

    [ https://issues.apache.org/jira/browse/EMPIREDB-191?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13755799#comment-13755799 ] 

Francis De Brabandere commented on EMPIREDB-191:
------------------------------------------------

Hi gdiao,

I'm not a spring specialist but the getConnection() documentation says this:

"Get a JDBC Connection, either from the current transaction or a new one."

If I understand this correctly connection opening and closing is supposed to be taken care of outside of the dao, the getConnection() just takes the current transaction's connection. The @Transactional annotations will take care of opening and closing connections.

More info there
http://static.springsource.org/spring/docs/3.0.x/reference/transaction.html
                
> The spring example not release connection cause connection pool exhausted.
> --------------------------------------------------------------------------
>
>                 Key: EMPIREDB-191
>                 URL: https://issues.apache.org/jira/browse/EMPIREDB-191
>             Project: Empire-DB
>          Issue Type: Bug
>          Components: Website
>    Affects Versions: empire-db-2.4.1
>            Reporter: gdiao
>            Assignee: Francis De Brabandere
>            Priority: Minor
>
>     public Integer insertEmployee(String firstName, String lastName, String gender, int departmentId) {
>         SampleDB db = getDB();
>         Connection conn = getConnection();
>         DBRecord rec = new DBRecord();
>         rec.create(db.EMPLOYEES);
>         rec.setValue(db.EMPLOYEES.FIRSTNAME, firstName);
>         rec.setValue(db.EMPLOYEES.LASTNAME, lastName);
>         rec.setValue(db.EMPLOYEES.GENDER, gender);
>         rec.setValue(db.EMPLOYEES.DEPARTMENT_ID, departmentId);
>         rec.update(conn);
>         // Return Employee ID
>         return rec.getInt(db.EMPLOYEES.EMPLOYEE_ID);
>     }
> above code should be coupled with a releaseConnection(conn); otherwise, above code will use up all the connection in connection pool.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira