Search code examples
javatomcatweb-servicesapache-axis

axis2 Web service. Where to put my own configuration


I have written a Web Service in Java using axis2 and the POJO deployment (to a Tomcat server). My service opens a connection to a MySQL database. To do that, I need the connection string. Where do I put the connection string, so I don't have to hard code it into the code? And how do I access it from code? I would like to set this parameter somewhere on the service level, not globally for the whole server. Is this possible?


Solution

  • You could use tomcat to configure the DB connectivity for you and then just look up the javax.sql.DataSource using JNDI.

    Have look at these for tomcat:

    Using JNDI would also mean that you automatically become a little more compatible in case you ever need to move to a different web container/app server.