View Single Post
  #6 (permalink)  
Old 11-02-2009, 05:06 PM
kminev kminev is offline
Member
 
Join Date: Oct 2009
Posts: 14
Rep Power: 0
kminev is on a distinguished road
Default
Hopefully this will clear things out and help find the solution.

I tried switching to BasicDataSource in my config file, but now tomcat can't compile my jar with the update applicaiton context file. I am guessing the issue is in m transaction bean configuration as shown below.

Here is the config once again:

Code:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClass" value="${db.driver}"/>
        <property name="jdbcUrl" value="${db.jdbcurl}"/>
        <property name="user" value="${db.username}"/>
        <property name="password" value="${db.password}"/>
        <property name="minPoolSize" value="0"/>
        <property name="maxPoolSize" value="15"/>
        <property name="initialPoolSize" value="3"/>
    </bean>
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>
    <bean id="authorizationDAO" class=" com.seventicks.re.dao.jdbc.AuthorizationImpl">
        <property name="transactionManager">
            <ref local="transactionManager"/>
        </property>
    </bean>
here I have bunch of other dao objects declaration nothing else

This is my implementation for my DAO objects:

Code:
public class CompanyImpl implements CompanyDAO {

    private static final String TABLENAME = "company";
    private DataSourceTransactionManager transactionManager;
    private SimpleJdbcTemplate simpleJdbcTemplate;
    private SimpleJdbcInsert insert;
    private DataSource ds;

    public void setTransactionManager(DataSourceTransactionManager transactionManager) {
        this.transactionManager = transactionManager;
        ds = transactionManager.getDataSource();
        simpleJdbcTemplate = new SimpleJdbcTemplate(ds);
        this.insert = new SimpleJdbcInsert(ds).withTableName(TABLENAME).usingGeneratedKeyColumns("objectId");
    }

    public Company getById(Long objId) {
        StringBuffer sb = new StringBuffer();
        sb.append(" AND c.objectId=:oid");

        MapSqlParameterSource msps = new MapSqlParameterSource();
        msps.addValue("oid", objId);

        List<Company> results = getCore(sb.toString(), msps);
        if (results.size() > 0) {
            return results.get(0);
        }
        return null;
    }
Any ideas!!! Thank you
Reply With Quote