-->
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.  [ 4 posts ] 
Author Message
 Post subject: driver loading issue, mysql connector 3, hibernate 2.1.1
PostPosted: Wed Feb 18, 2004 9:36 am 
Beginner
Beginner

Joined: Wed Feb 04, 2004 5:21 pm
Posts: 37
I started writing a little junit testcase to play around with hibernate, but apparently I dont event manage to create a proper session.

I have the MySQL driver jar in my class path, yet it fails to load.

Can anyone see any faults in my setup ?

HIBERNATE.CFG.XML

Code:
<hibernate-configuration>

    <session-factory>
   
      <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
       <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
      <property name="hibernate.connection.url">jdbc:mysql://localhost</property>
      <property name="hibernate.connection.username">torque</property>
      <property name="hibernate.connection.password">torque</property>
      <property name="hibernate.dialect">net.sf.hibernate.dialect.MySQLDialect</property>
      <property name="hibernate.show_sql">true</property>
      <property name="hibernate.connection.pool_size">20</property>

        <mapping resource="com/bluprinted/blagmodel/Consumer.hbm.xml"/>

    </session-factory>




ANT / STACK TRACE


Buildfile: build.xml

init:

test-compile:

test:
[junit] [INFO] Environment - -Hibernate 2.1.1
[junit] [INFO] Environment - -hibernate.properties not found
[junit] [INFO] Environment - -using CGLIB reflection optimizer
[junit] [INFO] Configuration - -configuring from resource: /hibernate.cfg.xml
[junit] [INFO] Configuration - -Configuration resource: /hibernate.cfg.xml
[junit] [INFO] Configuration - -Mapping resource: com/bluprinted/blagmodel/Consumer.hbm.xml
[junit] [INFO] Binder - -Mapping class: com.bluprinted.blagmodel.Consumer -> consumer
[junit] [INFO] Configuration - -Configured SessionFactory: null
[junit] [INFO] Configuration - -processing one-to-many association mappings
[junit] [INFO] Configuration - -processing one-to-one association property references
[junit] [INFO] Configuration - -processing foreign key constraints
[junit] [INFO] Dialect - -Using dialect: net.sf.hibernate.dialect.MySQLDialect
[junit] [INFO] SettingsFactory - -Use outer join fetching: true
[junit] [INFO] DriverManagerConnectionProvider - -Using Hibernate built-in connection pool (not for production use!)

[junit] [INFO] DriverManagerConnectionProvider - -Hibernate connection pool size: 20
[junit] [INFO] DriverManagerConnectionProvider - -using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost

[junit] [INFO] TransactionManagerLookupFactory - -No TransactionManagerLookup configured (in JTA environment, use of
process level read-write cache is not recommended)
[junit] [WARN] SettingsFactory - -Could not obtain connection metadata <java.sql.SQLException: No suitable driver>ja
va.sql.SQLException: No suitable driver
[junit] at java.sql.DriverManager.getConnection(DriverManager.java:532)
[junit] at java.sql.DriverManager.getConnection(DriverManager.java:140)
[junit] at net.sf.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProv
ider.java:95)
[junit] at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)
[junit] at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1091)
[junit] at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:737)
[junit] at com.bluprinted.blagmodel.test.BaseTestCase.<clinit>(BaseTestCase.java:23)
[junit] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[junit] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
[junit] at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
[junit] at org.apache.tools.ant.AntClassLoader.initializeClass(AntClassLoader.java:485)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>(JUnitTestRunner.java:240)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>(JUnitTestRunner.java:219)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeInVM(JUnitTask.java:822)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:556)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:532)
[junit] at org.apache.tools.ant.Task.perform(Task.java:341)
[junit] at org.apache.tools.ant.Target.execute(Target.java:309)
[junit] at org.apache.tools.ant.Target.performTasks(Target.java:336)
[junit] at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
[junit] at org.apache.tools.ant.Project.executeTargets(Project.java:1255)
[junit] at org.apache.tools.ant.Main.runBuild(Main.java:609)
[junit] at org.apache.tools.ant.Main.start(Main.java:196)
[junit] at org.apache.tools.ant.Main.main(Main.java:235)

[junit] [INFO] SettingsFactory - -Use scrollable result sets: false
[junit] [INFO] SettingsFactory - -JDBC 2 max batch size: 15
[junit] [INFO] SettingsFactory - -echoing all SQL to stdout
[junit] [INFO] SettingsFactory - -Query language substitutions: {}
[junit] [INFO] SettingsFactory - -cache provider: net.sf.ehcache.hibernate.Provider
[junit] [INFO] Configuration - -instantiating and configuring caches
[junit] [INFO] SessionFactoryImpl - -building session factory
[junit] [INFO] SessionFactoryObjectFactory - -no JNDI name configured
[junit] Running com.bluprinted.blagmodel.test.ConsumerTestCase
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0,331 sec
[junit] Testsuite: com.bluprinted.blagmodel.test.ConsumerTestCase
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0,331 sec
[junit] ------------- Standard Error -----------------
[junit] [WARN] JDBCExceptionReporter - -SQL Error: 0, SQLState: 08001
[junit] [ERROR] JDBCExceptionReporter - -No suitable driver
[junit] [ERROR] JDBCExceptionReporter - -Cannot open connection <java.sql.SQLException: No suitable driver>java.sql.
SQLException: No suitable driver
[junit] at java.sql.DriverManager.getConnection(DriverManager.java:532)
[junit] at java.sql.DriverManager.getConnection(DriverManager.java:140)
[junit] at net.sf.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProv
ider.java:95)
[junit] at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:257)
[junit] at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3157)
[junit] at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3140)
[junit] at net.sf.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:40)
[junit] at net.sf.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:19)
[junit] at net.sf.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:2158)
[junit] at com.bluprinted.blagmodel.test.ConsumerTestCase.testConsumer(ConsumerTestCase.java:29)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[junit] at java.lang.reflect.Method.invoke(Method.java:324)
[junit] at junit.framework.TestCase.runTest(TestCase.java:154)
[junit] at junit.framework.TestCase.runBare(TestCase.java:127)
[junit] at junit.framework.TestResult$1.protect(TestResult.java:106)
[junit] at junit.framework.TestResult.runProtected(TestResult.java:124)
[junit] at junit.framework.TestResult.run(TestResult.java:109)
[junit] at junit.framework.TestCase.run(TestCase.java:118)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:208)
[junit] at junit.framework.TestSuite.run(TestSuite.java:203)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:325)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeInVM(JUnitTask.java:848)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:556)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:532)
[junit] at org.apache.tools.ant.Task.perform(Task.java:341)
[junit] at org.apache.tools.ant.Target.execute(Target.java:309)
[junit] at org.apache.tools.ant.Target.performTasks(Target.java:336)
[junit] at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
[junit] at org.apache.tools.ant.Project.executeTargets(Project.java:1255)
[junit] at org.apache.tools.ant.Main.runBuild(Main.java:609)
[junit] at org.apache.tools.ant.Main.start(Main.java:196)
[junit] at org.apache.tools.ant.Main.main(Main.java:235)

[junit] ------------- ---------------- ---------------

[junit] Testcase: testConsumer took 0,311 sec
[junit] Caused an ERROR
[junit] Cannot open connection
[junit] net.sf.hibernate.JDBCException: Cannot open connection
[junit] at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:260)
[junit] at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3157)
[junit] at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3140)
[junit] at net.sf.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:40)
[junit] at net.sf.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:19)
[junit] at net.sf.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:2158)
[junit] at com.bluprinted.blagmodel.test.ConsumerTestCase.testConsumer(ConsumerTestCase.java:29)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[junit] Caused by: java.sql.SQLException: No suitable driver
[junit] at java.sql.DriverManager.getConnection(DriverManager.java:532)
[junit] at java.sql.DriverManager.getConnection(DriverManager.java:140)
[junit] at net.sf.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProv
ider.java:95)
[junit] at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:257)
[junit] ... 30 more

[junit] Testcase: testConsumer
[junit] TEST com.bluprinted.blagmodel.test.ConsumerTestCase FAILED


ANT TASK

Code:
   <target name="test" depends="init,test-compile" description="run all unit tests">
      <junit printsummary="true">
         <classpath>
            <pathelement location="${build.classes}"/>
             <fileset dir="${runtime.lib}">
               <include name="**/*.jar"/>
             </fileset>
         </classpath>
         <formatter type="plain" usefile="false"/>
         <test name="com.bluprinted.blagmodel.test.ConsumerTestCase"/>
      </junit>
   </target>




CONTENT OF /lib

17-12-2003 15:07 737.884 ant.jar
17-12-2003 15:07 2.717 apache.license.txt
17-12-2003 15:07 235.686 c3p0.jar
17-12-2003 15:07 18.258 c3p0.license.txt
17-12-2003 15:07 288.855 cglib2.jar
17-12-2003 15:07 165.119 commons-collections.jar
17-12-2003 15:07 100.776 commons-dbcp.jar
17-12-2003 15:07 63.980 commons-lang.jar
17-12-2003 15:07 31.605 commons-logging.jar
17-12-2003 15:07 39.523 commons-pool.jar
16-02-2004 20:00 <DIR> compile-only
17-12-2003 15:07 171.071 concurrent.jar
17-12-2003 15:07 17.978 connector.jar
17-12-2003 15:07 9.790 connector.licence.txt
17-12-2003 15:07 486.522 dom4j.jar
17-12-2003 15:07 42.030 ehcache.jar
17-12-2003 15:06 889.958 hibernate2.jar
17-12-2003 15:07 104.359 jaas.jar
17-12-2003 15:07 9.863 jaas.licence.txt
17-12-2003 15:07 156.143 jboss-cache.jar
17-12-2003 15:07 287.213 jboss-common.jar
17-12-2003 15:07 576.871 jboss-jmx.jar
17-12-2003 15:07 170.923 jboss-system.jar
17-12-2003 15:07 293.789 jcs.jar
17-12-2003 15:07 6.727 jdbc2_0-stdext.jar
17-12-2003 15:07 7.932 jdbc2_0-stdext.licence.txt
17-12-2003 15:07 1.331.869 jgroups.jar
17-12-2003 15:07 8.812 jta.jar
17-12-2003 15:07 9.830 jta.licence.txt
17-12-2003 15:07 121.070 junit.jar
17-12-2003 15:07 352.668 log4j.jar
05-01-2004 12:16 153.276 middlegen-2.0-vo.jar
05-01-2004 12:16 45.042 middlegen-hibernate-plugin-2.0-vo.jar
13-01-2004 16:15 235.774 mysql-connector-java-3.0.10-stable-bin.jar
17-12-2003 15:07 13.091 odmg.jar
17-12-2003 15:07 671.546 optional.jar
17-12-2003 15:07 110.208 oscache.jar
17-12-2003 15:07 475.943 proxool.jar
17-12-2003 15:07 2.008 README.txt
17-12-2003 15:07 30.602 swarmcache.jar
17-12-2003 15:07 997.276 xalan.jar
17-12-2003 15:07 895.813 xerces.jar
17-12-2003 15:07 123.705 xml-apis.jar
42 fil(er) 10.494.105 byte
3 mappe(r) 2.406.436.864 byte ledig

WHAT I TRY TO DO, BUT NEVER GET TO


Code:
   public void testConsumer() throws HibernateException {
      Session session = currentSession();

      Transaction tx= session.beginTransaction();

      Consumer joe = new Consumer();
      joe.setFirstName("Joe");
      joe.setSurname("Schmoe");

      session.save(joe);
      tx.commit();

      closeSession();
      
   }


Top
 Profile  
 
 Post subject: same problem with hibernate 2.1.2
PostPosted: Wed Feb 18, 2004 10:05 am 
Beginner
Beginner

Joined: Wed Feb 04, 2004 5:21 pm
Posts: 37
just tried upgrading to 2.1.2, I still get the same exception


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 18, 2004 10:28 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Just out of interest - why is your dialect stated twice?

Are you sure the url is correct: jdbc:mysql://localhost I'm not that familiar with MySQL but don't you need to specify a db?

Also make 100% sure that the library is being included in the classpath. Use ant -versbose to execute the ant task - this should generate the classpath.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 18, 2004 10:39 am 
Beginner
Beginner

Joined: Wed Feb 04, 2004 5:21 pm
Posts: 37
Was just trying different properties, hoping it might make a difference

You were right, I needed to specify the database, works now it seems, thanks.


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