Reputation: 1950
I have the following host entry in my server.xml for tomcat
<Host name="app.andrewbucknell.com" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="app" debug="5"/>
<Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="app_access_log." suffix=".txt"
pattern="common"/>
<Resource name="jdbc/appDB" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="appuser" password="apppass" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/appDB"/>
</Host>
I am trying to move to Jetty but cant figure out where to put the resource declaration.
What I want is for the resource declaration to wind up being server specific rather than app specific. Any suggestions?
Upvotes: 1
Views: 3413
Reputation: 1828
Not an expert of jetty, but from their documentation page you could achieve what you want by creating a jetty.xml or WEB-INF/jetty-env.xml file and define the datasource in it as follows:
<New id="jdbc/appDB" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/appDB</Arg>
<Arg>
<New class="com.mysql.jdbc.Driver">
<Set name="Url">jdbc:mysql://localhost:3306/appDB</Set>
<Set name="User">appuser</Set>
<Set name="Password">apppass</Set>
</New>
</Arg>
</New>
Upvotes: 1