-->
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: Yet another java.sql.SQLException: No suitable driver
PostPosted: Mon Dec 19, 2005 7:59 am 
Newbie

Joined: Mon Dec 19, 2005 7:04 am
Posts: 2
Hallo.

I am just starting with hibernate. While walking trought road map for new users, i got stuck at: the example should run successfully.
I've:
1) Downloaded and unziped hibernate to C:\Java\Hibernate-3.1
2) Copied antlr-2.7.6rc1.jar and junit-3.8.1.jar to ANT_HOME/lib and mysql-connector-java-3.1.11-bin.jar to HIBERNATE/lib
3) In HIBERNATE/etc/hibernate.properties i've made these changes:
Code:
## HypersonicSQL
#hibernate.dialect org.hibernate.dialect.HSQLDialect
#hibernate.connection.driver_class org.hsqldb.jdbcDriver
#hibernate.connection.username sa
#hibernate.connection.password
##hibernate.connection.url jdbc:hsqldb:hsql://localhost
##hibernate.connection.url jdbc:hsqldb:test
#hibernate.connection.url jdbc:hsqldb:.

## MySQL
hibernate.dialect org.hibernate.dialect.MySQLDialect
#hibernate.dialect org.hibernate.dialect.MySQLInnoDBDialect
#hibernate.dialect org.hibernate.dialect.MySQLMyISAMDialect
hibernate.connection.driver_class org.gjt.mm.mysql.Driver
#hibernate.connection.driver_class com.mysql.jdbc.Driver
hibernate.connection.url jdbc:mysql://localhost/test
hibernate.connection.username root
hibernate.connection.password 1234

Connection string jdbc:mysql://localhost/test work ok with my driver (in other java programs).

4) I got java.sql.SQLException: No suitable driver exception when ant eg In C:\Java\Hibernate-3.1 (full log is down)

What did I missunderstood?

I know that this topic is similar/same as: ...,..., ..., etc... but i was unable to find solution using these topics and faq or this :-(

Thank You for replay.
Adam


Details
Hibernate version: 3.1
Mapping documents: default sample provided by hibernate
Code between sessionFactory.openSession() and session.close():
Name and version of the database you are using: MySQL 5.0.15-nt
Problem related? env fragment:
Code:
ANT_HOME=C:\Java\Ant
CLASSPATH=C:\Java\jdk1.5.0\lib;C:\Java\hibernate-3.1\lib;C:\Java\mysql-connector-java-3.1.11\mysql-connector-java-3.1.11-bin.jar
JAVA_HOME=C:\Java\jdk1.5.0

Full stack trace of any exception that occurs:
Code:
Buildfile: build.xml
  [taskdef] Could not load definitions from resource checkstyletask.properties. It could not be found.
  [taskdef] Could not load definitions from resource clovertasks. It could not be found.

eg:
     [echo] remember to place your JDBC driver in the lib directory
     [java] 11:29:32,295  INFO Environment:479 - Hibernate 3.1
     [java] 11:29:32,315  INFO Environment:494 - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=ocom.mysql.jdbc.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider, hibernate.max_fetch_depth=1, hibernate.dialect=org.hibernate.dialect.MySQLDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.format_sql=true, hibernate.query.substitutions=yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=root, hibernate.cache.region_prefix=hibernate.test, hibernate.proxool.existing_pool=true, hibernate.connection.url=jdbc:mysql://localhost/test, hibernate.connection.password=****, hibernate.jdbc.batch_versioned_data=true, hibernate.connection.pool_size=1}
     [java] 11:29:32,325  INFO Environment:524 - using java.io streams to persist binary types
     [java] 11:29:32,325  INFO Environment:525 - using CGLIB reflection optimizer
     [java] 11:29:32,335  INFO Environment:555 - using JDK 1.4 java.sql.Timestamp handling
     [java] 11:29:32,495  INFO Configuration:496 - Reading mappings from resource: org/hibernate/auction/AuctionItem.hbm.xml
     [java] 11:29:33,396  INFO HbmBinder:265 - Mapping class: org.hibernate.auction.AuctionItem -> AuctionItem
     [java] 11:29:33,636  INFO Configuration:496 - Reading mappings from resource: org/hibernate/auction/Bid.hbm.xml
     [java] 11:29:33,747  INFO HbmBinder:265 - Mapping class: org.hibernate.auction.Bid -> Bid
     [java] 11:29:33,827  INFO HbmBinder:780 - Mapping subclass: org.hibernate.auction.BuyNow -> Bid
     [java] 11:29:33,837  INFO Configuration:496 - Reading mappings from resource: org/hibernate/auction/User.hbm.xml
     [java] 11:29:33,917  INFO HbmBinder:265 - Mapping class: org.hibernate.auction.User -> AuctionUser
     [java] 11:29:33,927  INFO Configuration:1022 - processing extends queue
     [java] 11:29:33,937  INFO Configuration:1026 - processing collection mappings
     [java] 11:29:33,937  INFO HbmBinder:2276 - Mapping collection: org.hibernate.auction.AuctionItem.bids -> Bid
     [java] 11:29:33,937  INFO HbmBinder:2276 - Mapping collection: org.hibernate.auction.User.bids -> Bid
     [java] 11:29:33,937  INFO HbmBinder:2276 - Mapping collection: org.hibernate.auction.User.auctions -> AuctionItem
     [java] 11:29:33,937  INFO Configuration:1035 - processing association property references
     [java] 11:29:33,937  INFO Configuration:1057 - processing foreign key constraints
     [java] 11:29:34,317  INFO ProxoolConnectionProvider:104 - Configuring Proxool Provider using existing pool in memory: proxool.pool1
     [java] 11:29:34,317  INFO ProxoolConnectionProvider:166 - autocommit mode: false
     [java] 11:29:34,317  WARN SettingsFactory:103 - Could not obtain connection metadata
     [java] java.sql.SQLException: No suitable driver
     [java]    at java.sql.DriverManager.getConnection(DriverManager.java:545)
     [java]    at java.sql.DriverManager.getConnection(DriverManager.java:193)
     [java]    at org.hibernate.connection.ProxoolConnectionProvider.getConnection(ProxoolConnectionProvider.java:53)
     [java]    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
     [java]    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1859)
     [java]    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1152)
     [java]    at org.hibernate.auction.Main.main(Main.java:368)
     [java] 11:29:34,378  INFO Dialect:103 - Using dialect: org.hibernate.dialect.MySQLDialect
     [java] 11:29:34,388  INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
     [java] 11:29:34,398  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
     [java] 11:29:34,398  INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
     [java] 11:29:34,398  INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
     [java] 11:29:34,408  INFO SettingsFactory:144 - Scrollable result sets: disabled
     [java] 11:29:34,408  INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): disabled
     [java] 11:29:34,408  INFO SettingsFactory:160 - Connection release mode: auto
     [java] 11:29:34,418  INFO SettingsFactory:184 - Maximum outer join fetch depth: 1
     [java] 11:29:34,418  INFO SettingsFactory:187 - Default batch fetch size: 1
     [java] 11:29:34,418  INFO SettingsFactory:191 - Generate SQL with comments: disabled
     [java] 11:29:34,418  INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
     [java] 11:29:34,418  INFO SettingsFactory:338 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
     [java] 11:29:34,428  INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
     [java] 11:29:34,438  INFO SettingsFactory:203 - Query language substitutions: {no='N', yes='Y'}
     [java] 11:29:34,438  INFO SettingsFactory:209 - Second-level cache: enabled
     [java] 11:29:34,438  INFO SettingsFactory:213 - Query cache: disabled
     [java] 11:29:34,438  INFO SettingsFactory:325 - Cache provider: org.hibernate.cache.HashtableCacheProvider
     [java] 11:29:34,438  INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
     [java] 11:29:34,448  INFO SettingsFactory:233 - Cache region prefix: hibernate.test
     [java] 11:29:34,448  INFO SettingsFactory:237 - Structured second-level cache entries: disabled
     [java] 11:29:34,458  INFO SettingsFactory:264 - Statistics: disabled
     [java] 11:29:34,468  INFO SettingsFactory:268 - Deleted entity synthetic identifier rollback: disabled
     [java] 11:29:34,468  INFO SettingsFactory:283 - Default entity-mode: pojo
     [java] 11:29:34,588  INFO SessionFactoryImpl:153 - building session factory
     [java] 11:29:35,199  INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
     [java] 11:29:35,209  INFO Configuration:1022 - processing extends queue
     [java] 11:29:35,209  INFO Configuration:1026 - processing collection mappings
     [java] 11:29:35,209  INFO Configuration:1035 - processing association property references
     [java] 11:29:35,219  INFO Configuration:1057 - processing foreign key constraints
     [java] 11:29:35,219  INFO Configuration:1022 - processing extends queue
     [java] 11:29:35,219  INFO Configuration:1026 - processing collection mappings
     [java] 11:29:35,219  INFO Configuration:1035 - processing association property references
     [java] 11:29:35,219  INFO Configuration:1057 - processing foreign key constraints
     [java] 11:29:35,229  INFO SchemaExport:155 - Running hbm2ddl schema export
     [java] 11:29:35,229 DEBUG SchemaExport:173 - import file not found: /import.sql
     [java] 11:29:35,239  INFO SchemaExport:182 - exporting generated schema to database
     [java] 11:29:35,239 ERROR SchemaExport:208 - schema export unsuccessful
     [java] java.sql.SQLException: No suitable driver
     [java]    at java.sql.DriverManager.getConnection(DriverManager.java:545)
     [java]    at java.sql.DriverManager.getConnection(DriverManager.java:193)
     [java]    at org.hibernate.connection.ProxoolConnectionProvider.getConnection(ProxoolConnectionProvider.java:53)
     [java]    at org.hibernate.tool.hbm2ddl.SchemaExport$SuppliedConnectionProviderConnectionHelper.getConnection(SchemaExport.java:432)
     [java]    at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:183)
     [java]    at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:135)
     [java]    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:294)
     [java]    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1154)
     [java]    at org.hibernate.auction.Main.main(Main.java:368)
     [java] 11:29:35,239  INFO SessionFactoryImpl:353 - Checking 0 named HQL queries
     [java] 11:29:35,249  INFO SessionFactoryImpl:373 - Checking 0 named SQL queries
     [java] Setting up some test data
     [java] 11:29:35,499  WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: 08001
     [java] 11:29:35,499 ERROR JDBCExceptionReporter:72 - No suitable driver
     [java] Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Cannot open connection
     [java]    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:72)
     [java]    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
     [java]    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
     [java]    at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:318)
     [java]    at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:109)
     [java]    at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:137)
     [java]    at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
     [java]    at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1262)
     [java]    at org.hibernate.auction.Main.createTestAuctions(Main.java:285)
     [java]    at org.hibernate.auction.Main.main(Main.java:370)
     [java] Caused by: java.sql.SQLException: No suitable driver
     [java]    at java.sql.DriverManager.getConnection(DriverManager.java:545)
     [java]    at java.sql.DriverManager.getConnection(DriverManager.java:193)
     [java]    at org.hibernate.connection.ProxoolConnectionProvider.getConnection(ProxoolConnectionProvider.java:53)
     [java]    at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:315)
     [java]    ... 6 more
    [list=][/list]
    Code:


    Top
     Profile  
     
     Post subject:
    PostPosted: Mon Dec 19, 2005 9:28 am 
    Newbie

    Joined: Mon Aug 01, 2005 7:33 am
    Posts: 18
    Location: UK
    I would suggest that the MySql driver has not been made available in the classpath of the server trying to get the driver - the hibernate application. If you add the driver jar file to the lib dir of the application (or whereever you are deploying) it should work fine.


    Top
     Profile  
     
     Post subject:
    PostPosted: Mon Dec 19, 2005 5:59 pm 
    Newbie

    Joined: Mon Dec 19, 2005 7:04 am
    Posts: 2
    Sorry, some kind of missunerstanding.
    More specifiacions stuff: I have no application or project in any IDE, yet. I've only followed road map for new users. They say:
    Quote:
    - Download Hibernate 3.1 and extract the archive
    - place your JDBC driver jar file in the lib directory
    - edit etc/hibernate.properties, specifying connection settings for your database (Hibernate will create a schema for the demo automatically)
    - from a command prompt in the install dir
    ... - if you have Ant installed (and copied antlr.jar and junit.jar to ANT_HOME/lib), type ant eg
    ... - if not, type build eg under Windows
    ... - the example should run successfully


    And this is as far as i got. Example has failed to build. :-(


    Top
     Profile  
     
     Post subject:
    PostPosted: Tue Dec 20, 2005 4:14 am 
    Newbie

    Joined: Mon Aug 01, 2005 7:33 am
    Posts: 18
    Location: UK
    Well from looking at the output your app has read the config correctly etc. I am at a loss really - I think it is more likely to be something simple as apposed to complex - like paths for ant/java/path/hibernate ... but as to which I don't know just by looking at the output. If in your shoes I would reduce any assumptions and then start again. Take the hibernate example stuff. extract it again then redeploy and see what happens.

    Sorry no more use than that.

    Good luck.
    S


    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.