tomcat6 - tomcat: how can i place parameters in web.xml and fetch them in my application? -
I want to store DB connection information in the application web.xml file and want to bring it into the application.
Thank you!
2) In your web.xml Link to your resource pool
P>
eg (Tomcat 5.5 and above).
I have an example_des (data source) in the connection pool, and here I your web.xml
& lt; resource ref & gt; & Lt; description & gt; database connection, for example & lt; / description & gt; & LT; race-referee-name & gt; JDBC / Example_DS & lt; / race-referee-name & gt; & lt; Press Type & gt; javax.sql.DataSource & lt; / Race Type & to gt; & LT; Race Writing & gt; container & lt; / race Writing & gt; & LT; Race sharing-scope and shared gt; the qualified & lt; / race sharing the room & gt; & Lt; / resource ref & gt;
the
& lt; resource name = "jdbc / example_ds" auth = "container" types = "Javax.sql.DataSource" maxActive = "100" maxIdle = "30" maxwait = "10000" username = "YOURUSERNAMEHERE" password = "YOURPASSWORDHERE" driverClassName = "com.mysql.jdbc.Driver" url = "JDBC: mysql: // localhost: 3306 / DATABASEHERE autoReconnect = true" removeAbandoned = "true" RemoveAbandonedTimeout = "60" log expired = "true" testonbase = "true" verification = "selection1" />
Obviously, you can see that I am using MySQL here.
& lt; Resources / & gt;
allows you to create a connection pool (in Tomkat)
In JBoss ....
example
then the user & lt; Resource Ref & gt;
that I left earlier in Jboss to map it to my DS. Deploy your DS.xml file to / Server / Default / Deployed / Folder and restart JBoss.
Once you have completed, you can call it using Java in context.
Comments
Post a Comment