Posts Tagged ‘Spring’

Organizing Codebase in large Projects

Tuesday, July 10th, 2007

In this presentation Juergen Hoeller from Interface21, the company behind the Spring Framework, gives an interesting insight to the problems that occur when parting a big codebase into packages as you usually do in Java.
He also gives examples for bad practices and advices how to do it better to avoid the problems mainly occuring from cycles in package dependencies.

See it here.

Spring Framework and the JdbcDaoSupport

Tuesday, July 10th, 2007

Spring offers a handy class to implement DAO support with JDBC. Its called JdbcDaoSupport and offers methods to access the DataSource in your application context configuration. Here´s an example from the book “Java Development with the Spring Framework“:

public class TestJdbcDao extends JdbcDaoSupport {
    private final static String QUERY = "select count(*) from dual";
    public int getTestAccount(){
        return getJdbcTemplate().queryForInt(QUERY);
    }
}

And the corresponding dataAccessContext.xml

<bean id="dao" class="TestJdbcDao">

<property name="dataSource">

<ref local="dataSource"/>

</property>

</bean>