Created
May 22, 2013 05:46
-
-
Save sbose78/5625490 to your computer and use it in GitHub Desktop.
The config files used for Db Connection pooling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<Context path="/udhc-eclipse-tomcat6" docBase="udhc-eclipse-tomcat6" reloadable="true" crossContext="true"> | |
<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource" | |
maxActive="20" maxIdle="5" | |
username="root" password="qwerty" | |
driverClassName="com.mysql.jdbc.Driver" | |
url="jdbc:mysql://localhost:3306/udhc_local_db" /> | |
<Resource name="jdbc/awsDB" auth="Container" type="javax.sql.DataSource" | |
testWhileIdle="true" | |
maxActive="30" | |
maxIdle="5" | |
maxWait="3000" | |
removeAbandoned="true" | |
logAbandoned="false" | |
removeAbandonedTimeout="3" | |
timeBetweenEvictionRunsMillis="300000" | |
username="sbose78" password="XXXXXX" | |
driverClassName="com.mysql.jdbc.Driver" | |
url="jdbc:mysql://udhc-amazoXXXXXXnortheast-1.rds.amazonaws.com:3306/health?autoReconnect=true" /> | |
</Context> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Connection getPooledDbConnection() throws NamingException, SQLException | |
{ | |
Context initContext = new InitialContext(); | |
DataSource ds = (DataSource)initContext.lookup("java:/comp/env/jdbc/TestDB"); | |
Connection conn = ds.getConnection(); | |
return conn; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resource-ref> | |
<description>DB Connection</description> | |
<res-ref-name>jdbc/awsDB</res-ref-name> | |
<res-type>javax.sql.DataSource</res-type> | |
<res-auth>Container</res-auth> | |
</resource-ref> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment