C:\apache-tomcat-6.0.44\conf\context.xml
<Context>
<!-- Default
set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource
name="jdbc/JNDINAME" auth="Container"
type="javax.sql.DataSource"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://HOST:PORT;DatabaseName=DATABASENAME"
username="USERNAME" password="PASSWORD"
maxActive="100" maxIdle="30" maxWait="10000"/>
</Context>
D:\apache-tomcat-8.0.30\conf\context.xml
<Resource name="jdbc/JNDINAME "
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url=" jdbc:sqlserver://HOST:PORT;DatabaseName=DATABASENAME"
username="USERNAME" password="PASSWORD"
maxTotal="100" maxIdle="30"
maxWaitMillis="10000"/>
Java code:
public static DataSource getNonTXDataSource() throws ServiceLocatorException
{
DataSource ds = null; String nonTxDataSource = "java:comp/env/jdbc/janusTXPool";
try { if (ctxService == null) { ctxService = new InitialContext(); } if (mapCache == null) { mapCache = Collections.synchronizedMap(new HashMap()); } if (mapCache.containsKey(nonTxDataSource)) { ds = (DataSource) mapCache.get(nonTxDataSource); } else { ds = (DataSource) ctxService.lookup(nonTxDataSource); mapCache.put(nonTxDataSource, ds); } } catch (NamingException objNamingException) { obDebug.log(JanusLogger.ERROR, objNamingException); throw new ServiceLocatorException("expcode", "Database connection parameters could not be located"); } return ds; }
No comments:
Post a Comment