-->
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.  [ 2 posts ] 
Author Message
 Post subject: java.sql.SQLException: No suitable driver
PostPosted: Sun Mar 13, 2005 8:19 pm 
Newbie

Joined: Fri Mar 04, 2005 3:00 pm
Posts: 14
Hello,

I've seen this subject discussed before.... but didn't help, this is why i am posting a new message with the same subject.

I seem to get a weird error when trying to initialize my Configuration from an xml file. If i try to initialize it from a properties file with the same configuration everythins works fine.
Here are my two configuration files:

hibernate.cfg.xml

Code:
<hibernate-configuration>
   <session-factory name="foo">
      <property name="show_sql">true</property>
      <!-- database connection -->
        <property name="hibernate.connection.driver_class">com.sap.dbtech.jdbc.DriverSapDB</property>
          <property name="hibernate.dialect">org.hibernate.dialect.SAPDBDialect</property>
          <property name="hibernate.connection.url">jdbc\:sapdb\://localhost/LimsTest</property>
          <property name="hibernate.connection.username">sa</property>
          <property name="hibernate.connection.password">sa</property>
          <property name="hibernate.connection.pool_size">4</property>
          <property name="hibernate.statement_cache.size">100</property>
          <property name="hibernate.show_sql">true</property>
          <property name="hibernate.jdbc.batch_size">0</property>
          <property name="hibernate.cglib.use_reflection_optimizer">true</property>
   </session-factory>
</hibernate-configuration>



hibernate.properties

Code:
#Example hibernate properties
#Thu Mar 10 04:49:04 PST 2005
hibernate.connection.username=sa
hibernate.connection.password=sa
hibernate.dialect=org.hibernate.dialect.SAPDBDialect
hibernate.connection.url=jdbc\:sapdb\://localhost/LimsTest
hibernate.connection.driver_class=com.sap.dbtech.jdbc.DriverSapDB



the code for initializing :

Code:
cfg.configure();//should read cf.xml
Class[] classes = new Class[] {AdministratorInfo.class};
        for (int i = 0; i<classes.length; i++) {
            try {
                cfg.addClass(classes[i]);
            }           
            catch (MappingException me) {
                throw new DAOLayerException(me);
            }
  sf = cfg.buildSessionFactory();



And the stack trace when trying to use the xml file :

***********************************************
DEBUG 2005-03-13 15:41:41,091 ro.citrusmedia.lims.web.BaseDAO - removeAll(class ro.citrusmedia.lims.web.settings.AdministratorInfo)
INFO 2005-03-13 15:41:41,412 org.hibernate.cfg.Environment - Hibernate 3.0 beta 4
INFO 2005-03-13 15:41:41,422 org.hibernate.cfg.Environment - hibernate.properties not found
INFO 2005-03-13 15:41:41,442 org.hibernate.cfg.Environment - using CGLIB reflection optimizer
INFO 2005-03-13 15:41:41,442 org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
DEBUG 2005-03-13 15:41:41,442 ro.citrusmedia.lims.web.HibernateSession - creating current session
DEBUG 2005-03-13 15:41:41,442 ro.citrusmedia.lims.web.HibernateSession - building session factory
INFO 2005-03-13 15:41:41,442 org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
INFO 2005-03-13 15:41:41,442 org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
DEBUG 2005-03-13 15:41:43,645 org.hibernate.util.DTDEntityResolver - trying to locate http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath under org/hibernate/
DEBUG 2005-03-13 15:41:43,655 org.hibernate.util.DTDEntityResolver - found http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath
DEBUG 2005-03-13 15:41:44,156 org.hibernate.cfg.Configuration - show_sql=true
DEBUG 2005-03-13 15:41:44,156 org.hibernate.cfg.Configuration - hibernate.connection.driver_class=com.sap.dbtech.jdbc.DriverSapDB
DEBUG 2005-03-13 15:41:44,156 org.hibernate.cfg.Configuration - hibernate.dialect=org.hibernate.dialect.SAPDBDialect
DEBUG 2005-03-13 15:41:44,156 org.hibernate.cfg.Configuration - hibernate.connection.url=jdbc\:sapdb\://localhost/LimsTest
DEBUG 2005-03-13 15:41:44,156 org.hibernate.cfg.Configuration - hibernate.connection.username=sa
DEBUG 2005-03-13 15:41:44,156 org.hibernate.cfg.Configuration - hibernate.connection.password=sa
DEBUG 2005-03-13 15:41:44,156 org.hibernate.cfg.Configuration - hibernate.connection.pool_size=4
DEBUG 2005-03-13 15:41:44,156 org.hibernate.cfg.Configuration - hibernate.statement_cache.size=100
DEBUG 2005-03-13 15:41:44,156 org.hibernate.cfg.Configuration - hibernate.show_sql=true
DEBUG 2005-03-13 15:41:44,156 org.hibernate.cfg.Configuration - hibernate.jdbc.batch_size=0
DEBUG 2005-03-13 15:41:44,156 org.hibernate.cfg.Configuration - hibernate.cglib.use_reflection_optimizer=true
INFO 2005-03-13 15:41:44,156 org.hibernate.cfg.Configuration - Configured SessionFactory: foo
DEBUG 2005-03-13 15:41:44,166 org.hibernate.cfg.Configuration - properties: {hibernate.connection.password=sa, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=C:\Program Files\Java\j2re1.4.2_03\bin, java.vm.version=1.4.2_03-b02, hibernate.connection.username=sa, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=US, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=D:\radu\WORK\CLims\newLimsWebClient, java.runtime.version=1.4.2_03-b02, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\Program Files\Java\j2re1.4.2_03\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\radu\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, sun.java2d.fontpath=, java.library.path=C:\Program Files\Java\j2re1.4.2_03\bin;.;C:\WINDOWS\system32;C:\WINDOWS;c:\program files\sapdb\indep_prog\bin;c:\program files\sapdb\indep_prog\pgm;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;d:\software\applications\ant\apache-ant-1.6.2\bin, java.specification.name=Java Platform API Specification, java.class.version=48.0, hibernate.connection.pool_size=4, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, os.version=5.1, user.home=C:\Documents and Settings\radu, user.timezone=America/Los_Angeles, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.4, hibernate.connection.driver_class=com.sap.dbtech.jdbc.DriverSapDB, show_sql=true, user.name=radu, java.class.path=/d:/SOFTWARE/applications/eclipse/eclipse-dsk-3.1M4-win32/eclipse/plugins/org.eclipse.jdt.junit_3.1.0/junitsupport.jar;/d:/SOFTWARE/applications/eclipse/eclipse-dsk-3.1M4-win32/eclipse/plugins/org.eclipse.jdt.junit.runtime_3.1.0/junitruntime.jar;D:\radu\WORK\CLims\newLimsWebClient\classes;D:\radu\WORK\CLims\newLimsWebClient\limsclasses;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\ant-1.6.2.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\ant-antlr-1.6.2.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\ant-junit-1.6.2.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\ant-launcher-1.6.2.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\antlr-2.7.4.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\ant-swing-1.6.2.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\c3p0-0.8.4.5.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\cglib-full-2.0.2.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\cleanimports.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\commons-collections-2.1.1.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\commons-logging-1.0.4.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\concurrent-1.3.2.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\connector.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\dom4j-1.5.2.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\ehcache-1.1.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\hibernate3.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\jaas.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\jacc-1_0-fr.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\jaxen-1.1-beta-4.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\jboss-cache.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\jboss-common.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\jboss-jmx.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\jboss-remoting.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\jboss-system.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\jdbc2_0-stdext.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\jgroups-2.2.7.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\jta.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\junit-3.8.1.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\log4j-1.2.9.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\oscache-2.1.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\proxool-0.8.3.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\swarmcache-1.0rc2.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\versioncheck.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\xalan-2.6.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\xerces-2.6.2.jar;D:\radu\WORK\CLims\newLimsWebClient\hibernateLib\xml-apis.jar;D:\radu\WORK\CLims\newLimsWebClient\junitlib\junit.jar;D:\radu\WORK\CLims\newLimsWebClient\lib\bcel-5.1.jar;D:\radu\WORK\CLims\newLimsWebClient\lib\jboss-j2ee.jar;D:\radu\WORK\CLims\newLimsWebClient\lib\jdo-2.0.jar;D:\radu\WORK\CLims\newLimsWebClient\lib\jdori.jar;D:\radu\WORK\CLims\newLimsWebClient\lib\jpox-20050103.032035.jar;D:\radu\WORK\CLims\newLimsWebClient\lib\jpox-enhancer-20050103.032415.jar;D:\radu\WORK\CLims\newLimsWebClient\lib\log4j-1.2.8.jar;D:\radu\WORK\CLims\newLimsWebClient\lib\mail.jar;D:\radu\WORK\CLims\newLimsWebClient\lib\sapdbc.jar;D:\radu\WORK\CLims\newLimsWebClient\jbosslib\javax.servlet.jar;D:\radu\WORK\CLims\newLimsWebClient\jbosslib\jbossall-client.jar;D:\radu\WORK\CLims\newLimsWebClient\jbosslib\jboss-jmx.jar;D:\radu\WORK\CLims\newLimsWebClient\jbosslib\jbosssx.jar;D:\radu\WORK\CLims\newLimsWebClient\jbosslib\jbosssx-client.jar;D:\radu\WORK\CLims\newLimsWebClient\jbosslib\jboss-system.jar;D:\radu\WORK\CLims\newLimsWebClient\myfaceslib\commons-beanutils-1.6.1.jar;D:\radu\WORK\CLims\newLimsWebClient\myfaceslib\commons-codec-1.2.jar;D:\radu\WORK\CLims\newLimsWebClient\myfaceslib\commons-collections-3.0.jar;D:\radu\WORK\CLims\newLimsWebClient\myfaceslib\commons-digester-1.5.jar;D:\radu\WORK\CLims\newLimsWebClient\myfaceslib\commons-el.jar;D:\radu\WORK\CLims\newLimsWebClient\myfaceslib\commons-fileupload-1.0.jar;D:\radu\WORK\CLims\newLimsWebClient\myfaceslib\commons-logging.jar;D:\radu\WORK\CLims\newLimsWebClient\myfaceslib\commons-validator.jar;D:\radu\WORK\CLims\newLimsWebClient\myfaceslib\jakarta-oro.jar;D:\radu\WORK\CLims\newLimsWebClient\myfaceslib\jsp-2.0.jar;D:\radu\WORK\CLims\newLimsWebClient\myfaceslib\jstl.jar;D:\radu\WORK\CLims\newLimsWebClient\myfaceslib\log4j.jar;D:\radu\WORK\CLims\newLimsWebClient\myfaceslib\myfaces.jar;D:\radu\WORK\CLims\newLimsWebClient\myfaceslib\myfaces-components.jar;D:\radu\WORK\CLims\newLimsWebClient\myfaceslib\myfaces-jsf-api.jar;D:\radu\WORK\CLims\newLimsWebClient\myfaceslib\struts.jar;D:\radu\WORK\CLims\newLimsWebClient\config;D:\radu\WORK\CLims\newLimsWebClient\descriptors\metadata, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=C:\Program Files\Java\j2re1.4.2_03, sun.arch.data.model=32, hibernate.connection.url=jdbc\:sapdb\://localhost/LimsTest, hibernate.dialect=org.hibernate.dialect.SAPDBDialect, user.language=en, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, hibernate.cglib.use_reflection_optimizer=true, java.vm.info=mixed mode, java.version=1.4.2_03, java.ext.dirs=C:\Program Files\Java\j2re1.4.2_03\lib\ext, sun.boot.class.path=C:\Program Files\Java\j2re1.4.2_03\lib\rt.jar;C:\Program Files\Java\j2re1.4.2_03\lib\i18n.jar;C:\Program Files\Java\j2re1.4.2_03\lib\sunrsasign.jar;C:\Program Files\Java\j2re1.4.2_03\lib\jsse.jar;C:\Program Files\Java\j2re1.4.2_03\lib\jce.jar;C:\Program Files\Java\j2re1.4.2_03\lib\charsets.jar;C:\Program Files\Java\j2re1.4.2_03\classes, java.vendor=Sun Microsystems Inc., hibernate.jdbc.batch_size=0, file.separator=\, hibernate.session_factory_name=foo, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, hibernate.statement_cache.size=100, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, sun.cpu.isalist=pentium i486 i386}
INFO 2005-03-13 15:41:44,176 org.hibernate.cfg.Configuration - Mapping resource: ro/citrusmedia/lims/web/settings/AdministratorInfo.hbm.xml
DEBUG 2005-03-13 15:41:44,236 org.hibernate.util.DTDEntityResolver - trying to locate http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
DEBUG 2005-03-13 15:41:44,236 org.hibernate.util.DTDEntityResolver - found http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
INFO 2005-03-13 15:41:45,337 org.hibernate.cfg.HbmBinder - Mapping class: ro.citrusmedia.lims.web.settings.AdministratorInfo -> AdministatorInfo
DEBUG 2005-03-13 15:41:45,377 org.hibernate.cfg.HbmBinder - Mapped property: id -> admin_id
DEBUG 2005-03-13 15:41:45,758 org.hibernate.cfg.HbmBinder - Mapped property: password -> admin_password
DEBUG 2005-03-13 15:41:45,758 org.hibernate.cfg.Configuration - Preparing to build session factory with filters : {}
INFO 2005-03-13 15:41:45,758 org.hibernate.cfg.Configuration - processing extends queue
INFO 2005-03-13 15:41:45,758 org.hibernate.cfg.Configuration - processing collection mappings
INFO 2005-03-13 15:41:45,758 org.hibernate.cfg.Configuration - processing association property references
INFO 2005-03-13 15:41:45,758 org.hibernate.cfg.Configuration - processing foreign key constraints
INFO 2005-03-13 15:41:46,369 org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.SAPDBDialect
DEBUG 2005-03-13 15:41:46,379 org.hibernate.exception.SQLExceptionConverterFactory - Using dialect defined converter
INFO 2005-03-13 15:41:46,449 org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
INFO 2005-03-13 15:41:46,449 org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
INFO 2005-03-13 15:41:46,449 org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
INFO 2005-03-13 15:41:46,449 org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.classic.ClassicQueryTranslatorFactory
INFO 2005-03-13 15:41:46,519 org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
INFO 2005-03-13 15:41:46,549 org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
INFO 2005-03-13 15:41:46,549 org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 4
INFO 2005-03-13 15:41:46,549 org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
INFO 2005-03-13 15:41:46,729 org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.sap.dbtech.jdbc.DriverSapDB at URL: jdbc\:sapdb\://localhost/LimsTest
INFO 2005-03-13 15:41:46,739 org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=sa, password=sa}
DEBUG 2005-03-13 15:41:46,739 org.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0
DEBUG 2005-03-13 15:41:46,739 org.hibernate.connection.DriverManagerConnectionProvider - opening new JDBC connection
WARN 2005-03-13 15:41:46,759 org.hibernate.cfg.SettingsFactory - Could not obtain connection metadata
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:117)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1485)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1029)
at ro.citrusmedia.lims.web.HibernateSession.currentSession(HibernateSession.java:47)
at ro.citrusmedia.lims.web.BaseDAO.removeAll(BaseDAO.java:65)
at ro.citrusmedia.lims.web.settings.AdminDAOTest.testGetAllRemoveAll(AdminDAOTest.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:474)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:342)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:194)
************************************************

when i use the hibernate.properties file everything works ok ...

Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 14, 2005 5:59 am 
Newbie

Joined: Fri Mar 04, 2005 3:00 pm
Posts: 14
ok , figured it out

in the hibernate.cfg.xm the url shoul have been
hibernate.connection.url">jdbc:sapdb://localhost/LimsTest
and not
hibernate.connection.url">jdbc\:sapdb\://localhost/LimsTest

the '\' escape character shouldn't have been put there. In the properties file the '\' character is eliminated, when in xml is not, thus resulting in a erronated url.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.