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);
}