How to create a data source without combining in Tomcat

I am using a JNDI context to create a data source for JDBC drivers in a Tomcat context.xml file like this,

<Resource name="db/test" 
          type="javax.sql.DataSource" 
          driverClassName="com.test.jdbc.Driver"
          url="jdbc:fastdb://localhost:3306/session_db?autoReconnect=true&amp;connectTimeout=5000&amp;socketTimeout=5000"
          zeroDateTimeBehavior="convertToNull"
          username="dbuser"
          password="password"
          maxActive="100"
          maxWait="2"
          removeAbandoned="true"
          removeAbandonedTimeout="60"
          logAbandoned="true" />

By default, Tomcat will use the DBCP factory data source and will create the data source pools. The specific database and driver that we use already support lower-level consolidation, and the additional pool is actually detrimental to performance. Do I need to create a basic data source (without combining) using the JNDI resource so that I can switch between different databases with minimal configuration changes?

I know that I can write my own factory data source or use those from other drivers to achieve this, but I'm looking for an easier solution.

+1
4

, , , Spring JDBC Tomcat.

+2

, intialSize 1 maxActive 1 DBCP.

, , JNDI , -.

Edit:

: " , , ".

, , 1, . : " DataSource ", , .

, JNDI ( JNDI - -). - , , DBCP, , .

0

Oracle :

<Resource
        name="jdbc/aqds"
        auth="Container"
        type="oracle.jdbc.pool.OracleDataSource"
        factory="oracle.jdbc.pool.OracleDataSourceFactory"
        url="jdbc:oracle:thin:@localhost:1521:XE"
        user="MYUSER"
        password="MYPASSWORD" />
0

Source: https://habr.com/ru/post/1753372/


All Articles