Announcement Announcement Module
Collapse
No announcement yet.
Closing of jdbc connection? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Closing of jdbc connection?

    Newbie question

    I have defined a bean like this:

    <bean id="theDWHDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="oracle.jdbc.OracleDriver" />
    <property name="url" value="jdbc:oracle:thin:@alu006liv.utv-steria.sparebank1.no:4403:ERDD" />
    <property name="username" value="BLABLA" />
    <property name="password" value="BLABLA" />
    </bean>

    I use spring to inject this bean into my dao class by the normal way (setDataSource), and from this datasource I open a connection, like:

    dataSource.getConnection();

    My question is this: will I need to close the connection or does spring handle this for me?

    Currently I am not using the jdbctemplate, but if I do will spring then handle the connections for me?

  • #2
    When posting code please use the [ code][/code ] tags...

    If you obtain a connection yourself you will also need to take care of that connection and all the exceptions that can occur. Switch to a JdbcTemplate and spring will manage it for you.

    Comment

    Working...
    X