-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: net.sf.hibernate.JDBCException: Cannot open connection
PostPosted: Fri Oct 29, 2004 4:27 am 
Newbie

Joined: Fri Oct 29, 2004 4:21 am
Posts: 4
Hi All,

Iam getting the following error/eception while running my code
--------------------------------------------------------------------------
org.apache.jasper.JasperException: net.sf.hibernate.JDBCException: Cannot open connection

WARNING: Could not obtain connection metadata
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '
' for connect URL 'null'
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou
rce.java:780)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource
.java:540)
at net.sf.hibernate.connection.DatasourceConnectionProvider.getConnectio
n(DatasourceConnectionProvider.java:59)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.ja
va:73)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1
155)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.
java:789)
at com.edhand.example1.ConnectionFactory.<init>(Unknown Source)
at com.edhand.example1.ConnectionFactory.getInstance(Unknown Source)
at com.edhand.example1.ItemService.getItemList(Unknown Source)
at org.apache.jsp.pages.AddItem_jsp._jspService(AddItem_jsp.java:120)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
92)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:157)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
atcher.java:704)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(Applica
tionDispatcher.java:474)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationD
ispatcher.java:409)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDis
patcher.java:312)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.
java:1069)
at org.apache.struts.action.RequestProcessor.processForwardConfig(Reques
tProcessor.java:455)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:148
2)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(Standard
ContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:16
0)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:683)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.lang.NullPointerException
at java.lang.String.regionMatches(String.java:950)
at com.microsoft.jdbc.base.BaseURLParser.parse(Unknown Source)
at com.microsoft.jdbc.base.BaseDriver.acceptsURL(Unknown Source)
at java.sql.DriverManager.getDriver(DriverManager.java:232)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou
rce.java:773)
... 52 more
Oct 29, 2004 11:58:37 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use scrollable result sets: false
Oct 29, 2004 11:58:37 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use JDBC3 getGeneratedKeys(): false
Oct 29, 2004 11:58:37 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: false
Oct 29, 2004 11:58:37 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: echoing all SQL to stdout
Oct 29, 2004 11:58:37 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {no='N', true=1, yes='Y', false=0}
Oct 29, 2004 11:58:37 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: cache provider: net.sf.hibernate.cache.EhCacheProvider
Oct 29, 2004 11:58:37 AM net.sf.hibernate.cfg.Configuration configureCaches
INFO: instantiating and configuring caches
Oct 29, 2004 11:58:37 AM net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Oct 29, 2004 11:58:38 AM net.sf.hibernate.impl.SessionFactoryObjectFactory addIn
stance
INFO: Not binding factory to JNDI, no JNDI name configured
Oct 29, 2004 11:58:38 AM net.sf.hibernate.util.JDBCExceptionReporter logExceptio
ns
WARNING: SQL Error: 0, SQLState: null
Oct 29, 2004 11:58:38 AM net.sf.hibernate.util.JDBCExceptionReporter logExceptio
ns
SEVERE: Cannot create JDBC driver of class '' for connect URL 'null'
Oct 29, 2004 11:58:38 AM net.sf.hibernate.JDBCException <init>
SEVERE: Cannot open connection
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '
' for connect URL 'null'
--------------------------------------------------------------------------


I have done the following addition to my server .xml file (iam using tomcat 5.27)

--------------------------------------------------------------------------
<Context path="/quickstart" docBase="quickstart">
<Resource name="jdbc/quickstart" scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/quickstart">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<!-- DBCP database connection settings -->
<parameter>
<name>url</name>
<value>jdbc:microsoft:sqlserver://eip-in-a-box:1433;Database=TEST1</value>
</parameter>
<parameter>
<name>driverClassName</name><value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
</parameter>
<parameter>
<name>username</name>
<value>test</value>
</parameter>
<parameter>
<name>password</name>
<value>test</value>
</parameter>
<!-- DBCP connection pooling options -->
<parameter>
<name>maxWait</name>
<value>3000</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>100</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>
</ResourceParams>
</Context>
--------------------------------------------------------------------------

I've added following lines to my web.xml
--------------------------------------------------------------------------
<resource-ref> <description>My Datasource</description>
<res-ref-name>jdbc/quickstart</res-ref-name> <res-type> javax.sql.DataSource</res-type>
<res-auth>Container</res-auth> </resource-ref>
--------------------------------------------------------------------------

My hibernate.properties file looks like this
--------------------------------------------------------------------------
hibernate.connection.datasource java:comp/env/jdbc/quickstart
hibernate.dialect net.sf.hibernate.dialect.SQLServerDialect
--------------------------------------------------------------------------


Can any body suggest why am i getting such an error. The error says that URL and class are null . but i have mentioned all these properties inside the server.xml file.

please help!

thanks in advance
-Jim


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 29, 2004 8:31 am 
Senior
Senior

Joined: Fri Jun 18, 2004 10:17 am
Posts: 140
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '
' for connect URL 'null'

means that the connection factory is not finding the properties. does you properties file like exactly like you suggest? if so, you are missing = betweeen the key and value.

also, i suggest using the jTDS driver for SQL Server - it's much quicker than the one you are using .. jtds.sourceforge.net

have you been able to access your JNDI datasource using JDBC before or is this the first time?


Top
 Profile  
 
 Post subject: i have not tested JNDI
PostPosted: Mon Nov 01, 2004 12:23 am 
Newbie

Joined: Fri Oct 29, 2004 4:21 am
Posts: 4
Hi,

thanks for the reply. According to me the problem lies in the JNDI for the JDBC as all the info like class name, URL, user and pwd are mentioned under JNDI context information. but still error says URL is null and class is null that means there is some problem in JNDI. Can u check my server.xml file content to see if i've written it correctly.

As far as properties file is concerned it works without (=) as it is working for me in other samples as well.

-Jim


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 02, 2004 5:04 am 
Senior
Senior

Joined: Fri Jun 18, 2004 10:17 am
Posts: 140
post the jndi setup part


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 02, 2004 11:56 pm 
Newbie

Joined: Fri Oct 29, 2004 4:21 am
Posts: 4
Can u pls tell me how to post JNDI??

do i need to do some change in server.xml?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 03, 2004 5:04 am 
Senior
Senior

Joined: Fri Jun 18, 2004 10:17 am
Posts: 140
ok, you already did post it. i cannot see much wrong with it. our configuration is as follows

Do not add your <Context..> to server.xml. Create file in tomcat/conf/Catalina/localhost/nameofyourwebapp.xml and in there you define your context, e.g ours is as follows:

(By the way, have you made sure your database driver is in tomcat/common/lib? there should be 3 ms*.jars for the driver you appear to be using although I recommend jTDS).

<Context path="" docBase="/iq" reloadable="true">

<Resource name="jdbc/thedb" auth="Container" type="javax.sql.DataSource"/>

<ResourceParams name="jdbc/thedb">
<parameter><name>factory</name><value>org.apache.commons.dbcp.BasicDataSourceFactory</value></parameter>
<parameter><name>driverClassName</name><value>net.sourceforge.jtds.jdbc.Driver</value></parameter>
<parameter><name>url</name><value>jdbc:jtds:sqlserver://box:1433/db_iQ;charset=Cp1252;TDS=7.0</value></parameter>
<parameter><name>username</name><value>sa</value></parameter>
<parameter><name>password</name><value>bloop</value></parameter>
<parameter><name>maxActive</name><value>100</value></parameter>
<parameter><name>minIdle</name><value>10</value></parameter>
<parameter><name>maxIdle</name><value>10</value></parameter>
<parameter><name>maxWait</name><value>10000</value></parameter>
<parameter><name>validationQuery</name><value>SELECT 1 + 1</value></parameter>
<parameter><name>removeAbandoned</name><value>true</value></parameter>
<parameter><name>removeAbandonedTimeout</name><value>60</value></parameter>
</ResourceParams>
</Context>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.