16 Nisan 2018 Pazartesi

Tomcat JNDI

Resource tag
Veritabanı için gereken jar dosyaları tomcat/lib yani CATALINA_HOME/lib dizinine kopyalanır.

JNDI nesnesi context.xml veya server.xml içinde tanımlanabilir

HSQL
Örnek
Şöyle yaparız.
<Context>
<!-- HSQL -->
  <Resource name="jdbc/myDB" auth="Container"
    type="javax.sql.DataSource" driverClassName="org.hsqldb.jdbcDriver"
    url="jdbc:hsqldb:mem:mymemdb;shutdown=true" username="SA" password=""
    maxTotal="100" maxIdle="5" maxWaitMillis="10000"/>

  <Manager pathname=""/>
</Context>
MySql
Örnek
Şöyle yaparız.
<context>
<Resource
  name="java:comp/env/jdbc/webapp"
  auth="Container"
  type="javax.sql.DataSource"
  maxActive="100"
  maxIdle="30"
  maxWait="10000"
  driverClassName="com.mysql.jdbc.Driver"
  url="jdbc:mysql://localhost:3306/webapp"
  username="root"
  password="welcome001*"
    />
</context>
Oracle
Örnek
Şöyle yaparız.
<Resource auth="Container" 
  driverClassName="oracle.jdbc.OracleDriver"
  factory="oracle.jdbc.pool.OracleDataSourceFactory"
  maxActive="60"
  maxIdle="10"
  maxWaitMillis="10000"
  name="jdbc/TEST"
  password="test"
  removeAbandonedTimeout="300"
  type="oracle.jdbc.pool.OracleDataSource"
  url="jdbc:oracle:oci:@test"
  userName="test"/>
Örnek
Şöyle yaparız
<Resource auth="Container"
  driverClassName="oracle.jdbc.OracleDriver"
  maxTotal="10"
  maxIdle="3" 
  maxWaitMillis="10000"
  name="jdbc/AppDB" 
  password="mypassword"
  type="javax.sql.DataSource"
  url="jdbc:oracle:thin:@ 127.0.0.1:20300:MYSID"
  username="mypassword"/>
PostgreSQL
Örnek
Şöyle yaparız
<Context>
    <Resource
        name="jdbc/test"
        auth="Container"
        type="javax.sql.DataSource"
        username="test"
        password="test"
        driverClassName="org.postgresql.Driver"
        url="jdbc:postgresql://localhost:5440/test"/>
</Context>

Hiç yorum yok:

Yorum Gönder