0

I am creating a DB pool in server.xml like following

<Resource
    name="jdbc/repositoryDS" auth="Container" type="javax.sql.DataSource"
    maxActive="20" maxIdle="10" minIdle="2" initialSize="2" maxWait="10000"
    testOnBorrow="true" validationQuery="select 1 from dual"
    poolPreparedStatements="true"
    username="${database.login}" password="${database.password}"
    driverClassName="${connection.driver_class}"
    url="jdbc:mysql://${database.host}:${database.port}/cms?autoReconnect=true&amp;characterEncoding=utf8" />

All these properties are in my catalina.properties, and everything works fine.

Can we read these from a property from a external file say user home folder (db.propeties) . I tried setting the path in shared.loader= and common.loader= and setting path to my property file but it doesnt seem to work.

Is there any other way or I am missing something?

zeus321
  • 1
  • 1
  • so all web apps in your server will connect to one (and only one) database? seems like I am not understanding you correctly? what exactly is the problem you are trying to solve? – blurfus Nov 21 '14 at 07:25
  • Thats for a particular web app...The task is to place these properties from catalina.properties to a property file in user home, and tomcat should read it from there – zeus321 Nov 21 '14 at 07:25
  • To read property from user home means out of the context path use real path to file – Umesh Aawte Nov 21 '14 at 07:27
  • question, if it is for one particular app, why not place it in the WAR file for that app (or inside `/WEB-INF/lib`)? – blurfus Nov 21 '14 at 07:27
  • @UmeshA You mean property files relative to catalina.base could only be read? – zeus321 Nov 21 '14 at 07:29
  • @ochi ... That a different discussion all together.. Task here is diff..Can tomcat read a property file (like catalina.properties) from anyother path – zeus321 Nov 21 '14 at 07:30
  • I think this may be what you are looking for: http://stackoverflow.com/questions/13956651/externalizing-tomcat-webapp-config-from-war-file – blurfus Nov 21 '14 at 07:42
  • @ochi mulesoft link was maily fot the classpath issues.. and stackoverflow link was to get the path of property file in my java doc of that particular webapp. The webapp should only define the datasource(which is initialize in server.xml of tomcat) name in its web.xml. Further application can use as same. They need not know which property file its reading – zeus321 Nov 21 '14 at 07:54
  • Ok, my next question is for the purpose of what? I'm still not clear on what problem you are trying to solve. First, you say this is for a particular app (so a context-based configuration should suffice as this would work on a per-app basis) but then you say this is for an application first and then another application can re-use same datasource (so, it seems it's server-wide instead). Also, you are not telling us why the current (default) behaviour does't suit your needs. Can you tell us more about the why you need this? (i.e. what is the requirement for you to want to do it differently?) – blurfus Nov 21 '14 at 18:17

0 Answers0