Java 休眠配置文件
似乎我的配置文件有问题,但我真的不知道它可能是什么 我以前使用hibernate 3.6,现在使用hibernate 4.2,我忽略了一些重要的更改,但是文档似乎没有更改这部分 这是我的配置文件:Java 休眠配置文件,java,hibernate,configuration,mapping,config,Java,Hibernate,Configuration,Mapping,Config,似乎我的配置文件有问题,但我真的不知道它可能是什么 我以前使用hibernate 3.6,现在使用hibernate 4.2,我忽略了一些重要的更改,但是文档似乎没有更改这部分 这是我的配置文件: <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/Test</property>
<property name="connection.username">root</property>
<property name="connection.password">*****</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">10</property>
<property name="maxActive" value="10" />
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQL5Dialect</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">create</property>
<!-- Mapping files -->
<mapping resource="database/config/mapping/test.hbm.xml"/>
</session-factory>
</hibernate-configuration>
下面是返回语句:
mai 02, 2013 11:41:59 AM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
mai 02, 2013 11:41:59 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.2.0.Final}
mai 02, 2013 11:41:59 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
mai 02, 2013 11:41:59 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
mai 02, 2013 11:41:59 AM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: database/config/DBCreate.cfg.xml
mai 02, 2013 11:41:59 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: database/config/DBCreate.cfg.xml
Database unreachable.
我真的不明白怎么回事,也许有人能启发我。
很抱歉可能会造成干扰,如果我的帖子没有被改编,这是我的第一篇
致以最诚挚的问候。在connection.url中指定端口
我读过一篇文章,其中说在Hibernate4中,我们需要在配置文件的属性名标记中提到Hibernate关键字 样本格式为- 休眠早期版本 休眠版本4 观察property name标记中的hibernate关键字 具体联系如下:
当您按照上述注释更改XML文件时,您必须更改DTD定义。成功吗?我目前正在工作,今天晚些时候我会告诉您,我想可以,我会让您知道。我只是测试了它,它没有更改任何内容。@user2342594 Shucks,我很确定您需要指定端口,一定是别的东西。这可能是一个愚蠢的问题,但你的数据库是吗?是的,很明显,我在这里发布之前就试过了。我认为问题在于没有找到文件,我忽略了原因。cf:INFO:hh000206:hibernate.properties未找到我正在查找它好的,因此,确实是未加载的文件。现在我发现了一个新错误:mai 022013 10:58:05 PM org.hibernate.cfg.Configuration doConfigure INFO:hh000041:Configured SessionFactory:null。有什么想法吗?
mai 02, 2013 11:41:59 AM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
mai 02, 2013 11:41:59 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.2.0.Final}
mai 02, 2013 11:41:59 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
mai 02, 2013 11:41:59 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
mai 02, 2013 11:41:59 AM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: database/config/DBCreate.cfg.xml
mai 02, 2013 11:41:59 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: database/config/DBCreate.cfg.xml
Database unreachable.
<property name="connection.url">jdbc:mysql://localhost:3306/Test</property>
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration
DTD//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:mysql://localhost/noob</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
<!-- DB schema will be updated if needed -->
<property name="hbm2ddl.auto">create-drop</property>
<property name="show_sql">false</property>
<property name="format_sql">false</property>
</session-factory>
</hibernate-configuration>
<hibernate-configuration xmlns="http://www.hibernate.org/xsd/hibernate-
configuration">
<session-factory>
<!-- Database connection settings -->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/noob</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"></property>
<!-- JDBC connection pool (use the built-in) -->
<property name="hibernate.connection.pool_size">1</property>
<!-- SQL dialect -->
<property
name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="hibernate.current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property
name="hibernate.cache.provider_class">org.hibernate.cache.internal.NoCacheProvider
</property>
<!-- Echo all executed SQL to stdout -->
<property name="hibernate.show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hibernate.hbm2ddl.auto">update</property>
</session-factory>
</hibernate-configuration>
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">