hibernate问题

czstemp 2011-10-24 03:34:23
我的hibernate是3.6.7
mysql是5.1.59
jdbc是5.1.18
配置文件:
<hibernate-configuration>
<session-factory name="foo">
<property name="hibernate.connection.url">jdbc:mysql:localhost/hibernate_first</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">123456</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.show_sql">true</property>

</session-factory>
</hibernate-configuration>
运行
Configuration cfg = new Configuration().configure();
SchemaExport export = new SchemaExport(cfg);
export.create(true, true);

报错:
63 [main] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.2.0.Final
78 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.6.7.Final
78 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
78 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
78 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
110 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
110 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
156 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: foo
172 [main] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQLDialect
203 [main] INFO org.hibernate.cfg.Configuration - Hibernate Validator not found: ignoring
203 [main] INFO org.hibernate.tool.hbm2ddl.SchemaExport - Running hbm2ddl schema export
203 [main] INFO org.hibernate.tool.hbm2ddl.SchemaExport - exporting generated schema to database
203 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
203 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
203 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
219 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql:localhost/hibernate_first
219 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=root, password=****}
219 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaExport - schema export unsuccessful
java.sql.SQLException: No suitable driver found for jdbc:mysql:localhost/hibernate_first
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
at org.hibernate.tool.hbm2ddl.ManagedProviderConnectionHelper.prepare(ManagedProviderConnectionHelper.java:52)
at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:263)
at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:219)
at first.ExportDB.main(ExportDB.java:16)

...全文
210 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
greenpearl 2011-11-02
  • 打赏
  • 举报
回复
我使用Hibernate时能成功注册jdbc驱动程序,但是Tomcat说无法unregistered it 当关闭的时候。
number00fa 2011-10-24
  • 打赏
  • 举报
回复
哦,学习了
czstemp 2011-10-24
  • 打赏
  • 举报
回复
找到了,忘了写mapping resource了
nizhicheng 2011-10-24
  • 打赏
  • 举报
回复
jdbc:mysql://localhost:3306/hibernate_first
czstemp 2011-10-24
  • 打赏
  • 举报
回复
No suitable driver found for jdbc:mysql:localhost:3306/hibernate_first
nizhicheng 2011-10-24
  • 打赏
  • 举报
回复
property name="hibernate.connection.url">jdbc:mysql:localhost:3306/hibernate_first</property>
czstemp 2011-10-24
  • 打赏
  • 举报
回复
另外,我用log4j配置的输出加了slf4j-simple-1.6.3

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧