For some reasons I've to fine-tune the jdbc connecton, and I've found, the context.xml is the way I can do that. ( http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html#PostgreSQL )
So, I create context.xml:
<Context>
<Resource
name="jdbc/connectorDs"
auth="Container"
type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost/somedb"
username="pguser"
password="pgpw"
maxActive="20"
maxIdle="10"
maxWait="-1" />
</Context>
Add some config to web.xml:
<resource-ref>
<description>postgreSQL Datasource example</description>
<res-ref-name>jdbc/connectorDs</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
And modify the hibernate.cfg.xml:
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.datasource">java:jdbc/connectorDs</property>
<!-- THE ORIGINAL CONFIG -->
<!-- <property name="connection.url">jdbc:postgresql://localhost/somedb</property> -->
<!-- <property name="connection.username">pguser</property> -->
<!-- <property name="connection.password">pgpw</property> -->
But this kind of konfig doesn't work: SEVERE: Initial SessionFactory creation failed.org.hibernate.HibernateException: Could not find datasource
. I suppose the dataource not exist or the datasource connection string java:jdbc/connectorDs
is not proper. Anybody has any experience with it? How to set my connection propertly, or how to set additional properties on connection?
Thanks in advance.