Announcement Announcement Module
No announcement yet.
Getting DataBase configuration information in appliactionContext.xml from a file Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting DataBase configuration information in appliactionContext.xml from a file


    I am changing my application from JPA Jboss(EJB3) to Spring3 JPA. I am facing a migration issue for giving the database configuration in the Spring applicationcontext.xml . While using Jboss I was able to Configure the DataSource detail in one single file i.e the oracle-ds.xml. But when I migrated the application to Spring 3, i need to specify the DataBase information in the tag <bean id="dataSource" > of applicationContext.xml for all of my project modules , this is not acceptable for the project requirement. Does anyone have an Idea on how to put the database information in a single file out side of the application jar and the applicationContext.xml can read that file for creating the datasource.

    Thanks In advance

  • #2
    No you don't... The oracle-ds.xml registers a dtaasource in JNDI you can simply use a jndi lookup to retrieve it. You don't need to configure it by hand.


    • #3
      Actually we are planning to getrid of Jboss server and use only Tomcat 6 web server and spring will be residing in the weberver. So there wont be an application server and so we won't be having JNDI lookup. So the best way we thought of doing is to put the database information in a property file out of the context in an absolute location like E:/Spring_db/


      • #4
        Tomcat also provides JNDI... Simply put the datasource config in context.xml and presto.

        However if you want to contain the configuration inside the xml and don't use jndi, the easiest way is to put the url/user/password in a properties file some where on the file system and use a PropertyPlaceHolderConfigurer (check the ref guide) to add those properties.

        You could also completly externalize the datasource xml and leave it to the user to decide what to use.


        • #5
          Thank you Marten for your help. I was able to resolve my issue by using

          PropertyPlaceHolderConfigurer. Thank you very much..


          • #6
            Hi all

            We're removing jboss from our spring application, and also have problem with migrating oracle-ds.xml to bean declared datasource.
            What datasource should we use instead for oracle? com.mchange.v2.c3p0.ComboPooledDataSource? but I've not found such params in it as:

            What datasource does jboss use inside?