Announcement Announcement Module
No announcement yet.
Newbie Question - Difficulty configuring app to work with Oracle DB Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Newbie Question - Difficulty configuring app to work with Oracle DB


    Really new to Spring - and have tried to work through the Spring Ref Docs (esp. Section 3) - and I'm getting nowhere fast! There is so much to know about beans etc (also not something I am too used too yet).

    I am trying to adapt the following example code I found below to work with the Oracle Driver:

    OracleDao dao = new OracleDao();
    			DriverManagerDataSource dataSource = new DriverManagerDataSource();
    			// Inject the datasource into the dao
    So ignore the Derby stuff -I think this kind of thing can be wired up in a configuration XML file, which I think is stored in WEB-INF folder - can somone explain how you do that step and how it is you wire that up to some java code?

    However I might be totally wrong in my thinking here - so apologies.

    Many thanks

  • #2

    I suggest that you read
    first. You dont have to understand all of it, but you will get a good picture.

    You can configure your dataSource in the config. You will configure your
    Hibernate(?) session in the config too, and let Spring inject the dataSource
    into the session.

    So all you have to do in your code, is to work with the hibernate session .

    This is my config in the moment:
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
            <property name="driverClassName" value="${db.driver}"/>
            <property name="url" value="${db.url}"/>
            <property name="username" value="${db.user}"/>
            <property name="password" value="${db.password}"/>
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
            <property name="dataSource" ref="dataSource"/>
            <property name="jpaVendorAdapter">
                <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                    <property name="showSql" value="true" />
                    <property name="generateDdl" value="true"/>
                    <property name="databasePlatform" value="org.hibernate.dialect.MySQL5Dialect" />
                    <property name="database" value="MYSQL"/>
            <property name="jpaDialect">
                <bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"/>
    best regards


    • #3
      Do I need Spring???

      Just reading about Hibernate - sounds like it will do most of what I need, which is fairly basic - do I really need to bother with Spring as well?

      I just want to do some fairly basic inserts into 2 tables - parent and child relationship.


      • #4

        for a really smal project, without future :o, you can call and instance your
        objects directly. But I think it is a good thing to know about spring