Привет.
Я совсем недавно начал изучать Hibernate и..вообщем не пинайте сильно ,если это глупо:)
Вообщем хибернейт настроил, настроил mySql,завёл там пользователя ,навешал ему прав,создал схему для работы,проверил,всё работает.
При создании sessionFactory :
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
package util;
import org.hibernate.*;
import org.hibernate.cfg.*;
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
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);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
Вылетает Exception, совершенно мне не понятный...,обсмотрел инет,не нашёл разумительного ответа,почему так..:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
INFO: Bytecode provider name : cglib
31 . 08 . 2007 13 : 44 : 02 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1 . 4 java.sql.Timestamp handling
31 . 08 . 2007 13 : 44 : 02 org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
31 . 08 . 2007 13 : 44 : 02 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
31 . 08 . 2007 13 : 44 : 02 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : events/Event.hbm.xml
31 . 08 . 2007 13 : 44 : 03 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class : events.Event -> EVENTS
31 . 08 . 2007 13 : 44 : 03 org.hibernate.cfg.HbmBinder bindCollection
INFO: Mapping collection: events.Event.participants -> PERSON_EVENT
31 . 08 . 2007 13 : 44 : 03 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : events/Person.hbm.xml
31 . 08 . 2007 13 : 44 : 03 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class : events.Person -> PERSON
31 . 08 . 2007 13 : 44 : 03 org.hibernate.cfg.HbmBinder bindCollection
INFO: Mapping collection: events.Person.events -> PERSON_EVENT
31 . 08 . 2007 13 : 44 : 03 org.hibernate.cfg.HbmBinder bindCollection
INFO: Mapping collection: events.Person.emailAddresses -> PERSON_EMAIL_ADDR
31 . 08 . 2007 13 : 44 : 03 org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
31 . 08 . 2007 13 : 44 : 07 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
31 . 08 . 2007 13 : 44 : 07 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 1
31 . 08 . 2007 13 : 44 : 07 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
31 . 08 . 2007 13 : 44 : 08 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/test1
31 . 08 . 2007 13 : 44 : 08 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=denis, password=****}
Fri Aug 31 13 : 44 : 09 MSD 2007 TRACE: --> NonRegisteringDriver.java: 269 com.mysql.jdbc.NonRegisteringDriver.connect("jdbc:mysql://localhost:3306/test1", {user=denis, password= 1 })
Fri Aug 31 13 : 44 : 09 MSD 2007 TRACE: --> StringUtils.java: 1135 com.mysql.jdbc.StringUtils.startsWithIgnoreCase("jdbc:mysql://localhost:3306/test1", "jdbc:mysql:loadbalance://")
Fri Aug 31 13 : 44 : 09 MSD 2007 TRACE: --> StringUtils.java: 1119 com.mysql.jdbc.StringUtils.startsWithIgnoreCase("jdbc:mysql://localhost:3306/test1", 0 , "jdbc:mysql:loadbalance://")
Fri Aug 31 13 : 44 : 09 MSD 2007 TRACE: <-- StringUtils.java: 1119 com.mysql.jdbc.StringUtils.startsWithIgnoreCase(..) returning false
Fri Aug 31 13 : 44 : 09 MSD 2007 TRACE: <-- StringUtils.java: 1135 com.mysql.jdbc.StringUtils.startsWithIgnoreCase(..) returning false
Fri Aug 31 13 : 44 : 09 MSD 2007 TRACE: --> StringUtils.java: 1135 com.mysql.jdbc.StringUtils.startsWithIgnoreCase("jdbc:mysql://localhost:3306/test1", "jdbc:mysql:replication://")
Fri Aug 31 13 : 44 : 09 MSD 2007 TRACE: --> StringUtils.java: 1119 com.mysql.jdbc.StringUtils.startsWithIgnoreCase("jdbc:mysql://localhost:3306/test1", 0 , "jdbc:mysql:replication://")
Fri Aug 31 13 : 44 : 09 MSD 2007 TRACE: <-- StringUtils.java: 1119 com.mysql.jdbc.StringUtils.startsWithIgnoreCase(..) returning false
Fri Aug 31 13 : 44 : 09 MSD 2007 TRACE: <-- StringUtils.java: 1135 com.mysql.jdbc.StringUtils.startsWithIgnoreCase(..) returning false
Fri Aug 31 13 : 44 : 09 MSD 2007 TRACE: --> NonRegisteringDriver.java: 543 com.mysql.jdbc.NonRegisteringDriver.parseURL("jdbc:mysql://localhost:3306/test1", {user=denis, password= 1 })
Fri Aug 31 13 : 44 : 09 MSD 2007 TRACE: --> StringUtils.java: 1135 com.mysql.jdbc.StringUtils.startsWithIgnoreCase("jdbc:mysql://localhost:3306/test1", "jdbc:mysql://")
Fri Aug 31 13 : 44 : 09 MSD 2007 TRACE: --> StringUtils.java: 1119 com.mysql.jdbc.StringUtils.startsWithIgnoreCase("jdbc:mysql://localhost:3306/test1", 0 , "jdbc:mysql://")
Fri Aug 31 13 : 44 : 09 MSD 2007 TRACE: <-- StringUtils.java: 1119 com.mysql.jdbc.StringUtils.startsWithIgnoreCase(..) returning true
Fri Aug 31 13 : 44 : 09 MSD 2007 TRACE: <-- StringUtils.java: 1135 com.mysql.jdbc.StringUtils.startsWithIgnoreCase(..) returning true
Fri Aug 31 13 : 44 : 09 MSD 2007 TRACE: --> StringUtils.java: 1135 com.mysql.jdbc.StringUtils.startsWithIgnoreCase("jdbc:mysql://localhost:3306/test1", "jdbc:mysql:mxj://")
Fri Aug 31 13 : 44 : 09 MSD 2007 TRACE: --> StringUtils.java: 1119 com.mysql.jdbc.StringUtils.startsWithIgnoreCase("jdbc:mysql://localhost:3306/test1", 0 , "jdbc:mysql:mxj://")
Fri Aug 31 13 : 44 : 09 MSD 2007 TRACE: <-- StringUtils.java: 1119 com.mysql.jdbc.StringUtils.startsWithIgnoreCase(..) returning false
Fri Aug 31 13 : 44 : 09 MSD 2007 TRACE: <-- StringUtils.java: 1135 com.mysql.jdbc.StringUtils.startsWithIgnoreCase(..) returning false
Fri Aug 31 13 : 44 : 10 MSD 2007 TRACE: --> Messages.java: 77 com.mysql.jdbc.Messages.getString("Util.1")
Fri Aug 31 13 : 44 : 10 MSD 2007 TRACE: <-- Messages.java: 77 com.mysql.jdbc.Messages.getString(..) returning "
** BEGIN NESTED EXCEPTION **
"
Fri Aug 31 13 : 44 : 10 MSD 2007 TRACE: --> Messages.java: 77 com.mysql.jdbc.Messages.getString("Util.3")
Fri Aug 31 13 : 44 : 10 MSD 2007 TRACE: <-- Messages.java: 77 com.mysql.jdbc.Messages.getString(..) returning "
STACKTRACE:
"
Fri Aug 31 13 : 44 : 10 MSD 2007 TRACE: --> Messages.java: 77 com.mysql.jdbc.Messages.getString("Util.4")
Fri Aug 31 13 : 44 : 10 MSD 2007 TRACE: <-- Messages.java: 77 com.mysql.jdbc.Messages.getString(..) returning "
** END NESTED EXCEPTION **
"
Fri Aug 31 13 : 44 : 10 MSD 2007 TRACE: <-- NonRegisteringDriver.java: 543 com.mysql.jdbc.NonRegisteringDriver.parseURL(..) returning {HOST=localhost: 3306 , user=denis, password= 1 , DBNAME=test1}
Fri Aug 31 13 : 44 : 11 MSD 2007 TRACE: --> NonRegisteringDriver.java: 522 com.mysql.jdbc.NonRegisteringDriver.host({HOST=localhost: 3306 , user=denis, password= 1 , DBNAME=test1})
Fri Aug 31 13 : 44 : 11 MSD 2007 TRACE: <-- NonRegisteringDriver.java: 522 com.mysql.jdbc.NonRegisteringDriver.host(..) returning "localhost:3306"
Как я понял,ошибка заключается в этом:
1.
com.mysql.jdbc.NonRegisteringDriver.connect("jdbc:mysql://localhost:3306/test1", {user=denis, password= 1 })
Далее там идёт безумное логирование...,но ничего интересного там не пишется.И попытка соединения идёт постоянно,как в цикле
Но я не поленился,создал тестовое JDBC соединение и там всё было ok..
Вот конф.хибернейта:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/test1</property>
<property name="connection.username">denis</property>
<property name="connection.password"> 1 </property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size"> 1 </property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">false</property>
<!-- Drop and re-create the database schema on startup -->
<!-- <property name="hbm2ddl.auto">create</property>-->
<mapping resource="events/Event.hbm.xml"/>
<mapping resource="events/Person.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Подскажите,что я не так делаю...