2015-02-20 3 views
-1

Я новичок в спящем режиме, и мне было интересно, может ли кто-нибудь помочь мне на этом. Я пробовал все диалекты, но я не могу понять это. пожалуйста, помогитеhibernate.cfg.xml и диалект спящего режима

, когда я запустить простой Java, используя спящий режим для хранения данных в таблицу ... Feb 20, 2015 3:12:19 PM org.hibernate.cfg.Environment <clinit> INFO: HHH000206: hibernate.properties not found Feb 20, 2015 3:12:19 PM org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist Feb 20, 2015 3:12:19 PM org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator initiateService WARN: HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections Exception in thread "main" org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:98) at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:68) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:174) at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:85) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156) at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1827) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1785) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870) at org.mikias.kidane.hi.HibernateTest.main(HibernateTest.java:18)

вот мой hibernate.cfg.xml код

<?xml version='1.0' encoding='utf-8'?> 

<hibernate-configuration 
     xmlns="http://www.hibernate.org/xsd/hibernate-configuration" 
     xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <session-factory> 
    <!-- Database connection settings --> 
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property> 
    <property name="connection.url">jdbc:mysql://localhost:3306/konohashop</property> 
    <property name="connection.username">root</property> 
    <property name="connection.password">pass</property> 

    <!-- JDBC connection pool (use the built-in) --> 
    <property name="connection.pool_size">1</property> 

    <!-- SQL dialect --> 
    <property name="dialect">org.hibernate.dialect.MySQLDialect</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.internal.NoCacheProvider</property> 

    <!-- Echo all executed SQL to stdout --> 
    <property name="show_sql">true</property> 

    <!-- Drop and re-create the database schema on startup --> 
    <property name="hbm2ddl.auto">update</property> 
    <mapping resource="org.m.mi.UserDetails"/> 
    </session-factory> 
</hibernate-configuration> 

ответ

0

Я считаю, что это спящий режим. диалект проверьте ниже один раз.

<hibernate-configuration> 
    <session-factory> 
    <property name="hibernate.dialect"> 
     org.hibernate.dialect.MySQLDialect 
    </property> 
    <property name="hibernate.connection.driver_class"> 
     com.mysql.jdbc.Driver 
    </property> 

    <!-- Assume test is the database name --> 
    <property name="hibernate.connection.url"> 
     jdbc:mysql://localhost/test 
    </property> 
    <property name="hibernate.connection.username"> 
     root 
    </property> 
    <property name="hibernate.connection.password"> 
     root123 
    </property> 

    <!-- List of XML mapping files --> 
    <mapping resource="org.m.mi.UserDetails"/> 

</session-factory> 
</hibernate-configuration> 
+0

Я все еще получаю ту же ошибку..и не знаю как. Прошли дни, чтобы выяснить эту ошибку. – mike

+0

Соединение не может быть пустым, если «hibernate.dialect» не установлен, это показывает, что он должен быть hibernate.dialect, какую ошибку вы сейчас получаете? –

+0

Я получаю ту же ошибку, что и выше. – mike

Смежные вопросы