Wednesday, June 17, 2009

Tomcat + Postgresql +JNDI Datasource

JNDI datasource is probably the most convenient way to configure datasource in a J2EE environment. Here is what I have for my Tomcat server


${CATALINA_HOME}/conf/context.xml


auth="Container" type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/ramen"
username="ramen" password="ramen"/>


web.xml

xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
....


jdbc/ramenDataSource
javax.sql.DataSource
Container

....


spring configuration

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
">
...

..



Thats all :)

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home