Announcement Announcement Module
No announcement yet.
Database Persistence Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Database Persistence


    I've been going through the tutorial from the spring website using RAD 6, and everything has been going well so far. I'm at the database persistence part of it, where I have to add the following to the appname-servlet.xml:

        <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
          <property name="driverClassName"><value>org.hsqldb.jdbcDriver</value></property>
          <property name="url">
          <property name="username"><value>sa</value></property>
          <property name="password"><value></value></property>
        <bean id="prodManDao" class="db.ProductManagerDaoJdbc">
            <property name="dataSource">
                <ref bean="dataSource"/>
        <bean id="prodMan" class="bus.ProductManager">
            <property name="productManagerDao">
                <ref bean="prodManDao"/>
            <property name="products">
                    <ref bean="product1"/>
                    <ref bean="product2"/>
                    <ref bean="product3"/>
    I'm a little confused, but normally, for my other WAS applications to access the database, I add a resource reference to the web.xml file and then the WAS servers have the database name, server name, user ID, and password information for the database. Is there a way to configure the spring app to use the database name, server name, user ID and password information for the database from the WAS server?

    I don't even know if what I'm saying is making any sense.

    Thanks in advance for the help.

  • #2
    The DriverManagerDataSource is a simple datasource, which should be only used for testing. You can ofcourse lookup a DataSource which is configured on the application server. Take a look at this part of the reference guide.

    However I would for now suggest that you stay with the DriverManagerDataSource and then swap it with one which you lookup with JNDI. That way you will also see something of the power of Spring, configure a different datasource without any change of code.


    • #3
      The example you're using obviously uses it's own DataSource, suitable for testing. You could look one up instead if you wanted to. There are a few options here.