Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't connect to database using Tomcat 5.5 and Hibernate
    text
    copied!<p>Ok I have this weird problem. I'm using Tomcat 5.5 with Hibernate. I have added the resouce in the TOMCAT_HOME/conf/server.xml and also in my application's web.xml.<br> But I'm getting error when using Hibernate to build the session factory like this:</p> <pre><code> configure.buildSessionFactory() </code></pre> <p>But I'm getting this error:</p> <pre><code>[ WARN]21:04:29 (SettingsFactory.java:buildSettings:144) - Could not obtain connection metadata org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' </code></pre> <p>My server.xml resource configuration is like this:</p> <pre><code>&lt;Context path="/myApp" docBase="myApp" debug="0" reloadable="true" crossContext="true"&gt; &lt;Resource name="jdbc/myApp" auth="Container" type="javax.sql.DataSource" driverClass="com.microsoft.sqlserver.jdbc.SQLServerDriver" maxPoolSize="100" minPoolSize="5" acquireIncrement="5" user="username" password="1234" jdbcUrl="jdbc:sqlserver://192.168.1.108:1433;databaseName=myAppDB;autoReconnect=true" /&gt; &lt;/Context&gt; </code></pre> <p>My web.xml is like this:</p> <pre><code> &lt;resource-ref&gt; &lt;description&gt;DB Connection&lt;/description&gt; &lt;res-ref-name&gt;jdbc/myApp&lt;/res-ref-name&gt; &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt; &lt;res-auth&gt;Container&lt;/res-auth&gt; &lt;/resource-ref&gt; </code></pre> <p>This are the Hibernate properties I'm initializing in my Java code manually:</p> <pre><code>hibernate.useJndi = "true" hibernate.connection.datasource="java:/comp/env/jdbc/myApp" hibernate.connection.jndi.datasource="jdbc/myApp" hibernate.dialect="org.hibernate.dialect.SQLServerDialect" hibernate.current_session_context_class="thread" </code></pre> <p>So my hibernate.cfg.xml is basically empty, since configuration is done in Java code and through JNDI.</p> <p>The weird part is that if I only modify the server.xml and web.xml to use type="com.mchange.v2.c3p0.ComboPooledDataSource" along with factory="org.apache.naming.factory.BeanFactory" and leaving all other stuff the same, it works!!!</p> <p>Why is the above configuration not working? I took it from Tomcat 5.5 JNDI tutorial. I need to use it because after I get the above working I'm planning to extend org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory.</p> <p>Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload