-->
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.  [ 3 posts ] 
Author Message
 Post subject: Fehler beim DB connect!
PostPosted: Fri Nov 18, 2005 4:12 pm 
Newbie

Joined: Fri Nov 18, 2005 3:55 pm
Posts: 4
ich bekomme keine Datenbankverbindung mit Hibernate hin obwohl der mysql treiber vorhanden ist!! jemand ne ahnung?? :(


bekomme folgende exception:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:72)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:307)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:109)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:134)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1236)
at de.massenbuch.main.MasseManager.createMasse(MasseManager.java:23)
at de.massenbuch.main.MasseManager.main(MasseManager.java:16)
Caused by: 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.jdbc.ConnectionManager.openConnection(ConnectionManager.java:304)
... 6 more

allerdings funktioniert der connect mit dem code hier einwandfrei!
Code:
try{
          Class.forName("com.mysql.jdbc.Driver");
          Connection con =
              DriverManager.getConnection
              ("jdbc:mysql://localhost:3306/db", "dbUser", "dbPw");
          System.out.println("Connected to database! ");
       }catch(Exception e){
          e.printStackTrace();
        }


der code steht unmittelbar über
Code:
try {
            // Create the SessionFactory from hibernate.cfg.xml
            sessionFactory = new Configuration().configure().buildSessionFactory();
        } catch (Throwable ex) {
            // Make sure you log the exception, as it might be swallowed
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 3:46 am 
Beginner
Beginner

Joined: Mon Oct 24, 2005 9:46 am
Posts: 22
Location: Germany
wie sieht die hibernate.cfg.xml aus?


Top
 Profile  
 
 Post subject: Re: Fehler beim DB connect!
PostPosted: Mon Nov 21, 2005 10:58 am 
Newbie

Joined: Mon Nov 21, 2005 10:48 am
Posts: 7
Tach,

lass mich raten, das ganze passiert im Zusammenhang mit Tomcat 5.x?
Dann versuche die Verbindung über Apaches DBCP aufzubauen.
Ein Beispiel dafür gibt es in der Doku von MySQL Connector/J.

Ich hatte das selbe Problem. Mit dieser Umstellung ging das dann.
Woran das genau liegt, weiß ich nicht.
Ich vermute aber mal, dass der Tomcat da Probleme hat.


Gruß
Patrick


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