hibernate新手求助!!

今天下午学习使用hibernate,跟着视频做,可是控制台老报这个错误
02:03:12,171  WARN UserSuppliedConnectionProvider:23 - No connection properties specified - the user must supply JDBC connections
02:03:12,171 ERROR SchemaExport:202 - schema export unsuccessful
java.lang.UnsupportedOperationException: The user must supply a JDBC connection
 at org.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:30)
 at org.hibernate.tool.hbm2ddl.ManagedProviderConnectionHelper.prepare(ManagedProviderConnectionHelper.java:28)
 at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:180)
 at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:133)
 at com.test.hibernate.ExportDB.main(ExportDB.java:15)

视频就能运行成功,我的就不行,很是郁闷,

hibernate.cfg.xml配置如下:
        

            <!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="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">root</property>
                  <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
  
                  <mapping resource="com/test/hibernate/User.hbm.xml"/>
             </session-factory>
        </hibernate-configuration>

实体类User的映射文件配置:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
 "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
 "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
 <class name="com.test.hibernate.User">
  <id name="id">
   <generator class="uuid"/>
  </id>
  
  <property name="userName"/>
  <property name="password"/>
  <property name="createDate"/>
  <property name="expireDate"/>
 </class>
 
</hibernate-mapping>

下面是连接数据库的类:

package com.test.hibernate;

import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

public class ExportDB {


 public static void main(String[] args) {
  
  Configuration cfg = new Configuration().configure();
  
  SchemaExport export = new SchemaExport(cfg);
  
  export.create(true, true);
 }

}


希望路过高手不吝指导一下,感激不尽!!!!

posted on 2008-12-30 02:23 anyStar 阅读(1759) 评论(8)  编辑  收藏

评论

# re: hibernate新手求助!! 2009-03-10 14:39 222

换个 表名  回复  更多评论   

# re: hibernate新手求助!! 2009-03-10 19:44 xxxxx

和你一样的问题,不知道你能发下你的QQ么我加您,互相学习下.
看来我们都在看,勇哥的视频.  回复  更多评论   

# re: hibernate新手求助!! 2009-03-13 13:20 mm

我也是一样的问题 头很大  回复  更多评论   

# re: hibernate新手求助!![未登录] 2009-03-20 22:59 yang

我现在也在看王勇老师的视频,我QQ269676751,大家一起学习啊  回复  更多评论   

# re: hibernate新手求助!! 2009-04-01 16:41 木子日京

我也遇到了类似的问题,刚开始时还可以运行,可是我把Mysql重装了下就不行了,提示错误是
16:40:18,796 ERROR SchemaExport:202 - schema export unsuccessful
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.tool.hbm2ddl.ManagedProviderConnectionHelper.prepare(ManagedProviderConnectionHelper.java:28)
at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:180)
at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:133)
at com.ExprotDB.main(ExprotDB.java:15)
不知道怎么弄了!  回复  更多评论   

# re: hibernate新手求助!! 2009-04-01 18:40 木子日京

我的问题解决了呢!我看了一下你的配置文件,
<property name="hibernate.connection.url ">jdbc:mysql:///localhost/hibernate_first</property>改成
<property name="hibernate.connection.url ">jdbc:mysql://localhost/hibernate_first</property>试试,还有就是你的mysql的用户名和密码一下要正确哦!
  回复  更多评论   

# re: hibernate新手求助!![未登录] 2009-12-07 22:16 ice

same problem we meet!  回复  更多评论   

# re: hibernate新手求助!! 2011-09-26 11:10 lbblove

@222
hi,我也遇到这个问题,能加我qq么,296291859,以后多多向你请教。请问最后怎么解决呢···我也在看王勇老师的视频··  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航:
 
<2009年12月>
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

导航

统计

常用链接

留言簿(2)

随笔分类

随笔档案

文章档案

搜索

最新评论

阅读排行榜

评论排行榜