http://blog.csdn.net/oscar999/article/details/27237027
入门来说不错,如果hibernate数据写入不进数据库,问题一般出现在配置文件写的有问题。
如果这样写,就无法连接数据库
<session-factory>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.url">jdbc:mysql://localhost:3306/yangling</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
<property name="hibernate.connection.autocommit">true</property>
<property name="connection.driver_class">com.mysql.fabric.jdbc.FabricMySQLDriver</property>
<property name="myeclipse.connection.profile">com.mysql.jdbc.Driver</property>
<mapping resource="cn/nwsuaf/gov/model/Train_Teachers.hbm.xml"/>
</session-factory> -->
如果这样写,就没有问题
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/yangling</property>
<property name="connection.username">root</property>
<property name="connection.password"></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>
<!-- 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>
<!-- Names the annotated entity class -->
<mapping resource="cn/nwsuaf/gov/model/Train_Teachers.hbm.xml"/>
</session-factory>
问题出现在哪里了。