본문 바로가기
JAVA/spring

[Postgresql] JNDI 설정

by 개폰지밥 2019. 9. 4.
반응형

| applicationContext.xml

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="java:/comp/env/jdbc/postgres"/>
    <property name="resourceRef" value="true" />
</bean>

 

| context.xml

<!--connection tomcat jndi-->
<Context path="/">
    <Resource name="jdbc/postgres"
          auth="Container"
          type="javax.sql.DataSource"
          driverClassName="org.postgresql.Driver"
          url="jdbc:postgresql://ip주소:port/db명"
          username="username"
          password="password"
          maxActive="20"
          maxIdle="10"
          maxWait="-1"/>
</Context>

 

| web.xml

<!--tomcat datasource-->
<resource-ref>
    <description>jdbcJNDI</description>
    <res-ref-name>jdbc/miniCaPostgres</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

구동해보고 톰캣이 잘 연결되면 맞게 설정된 것이다.

 

반응형

'JAVA > spring' 카테고리의 다른 글

github sts(eclipse)  (0) 2019.09.11
intellij META-INF context.xml?  (1) 2019.09.10
intellij error - 2  (0) 2019.09.03
intellij error - 1  (2) 2019.09.02
[Spring] CRUD 구현  (0) 2019.08.28

댓글