hibernate新手求助!!

          今天下午學(xué)習(xí)使用hibernate,跟著視頻做,可是控制臺(tái)老報(bào)這個(gè)錯(cuò)誤
          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)

          視頻就能運(yùn)行成功,我的就不行,很是郁悶,

          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>

          實(shí)體類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>

          下面是連接數(shù)據(jù)庫(kù)的類:

          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);
           }

          }


          希望路過(guò)高手不吝指導(dǎo)一下,感激不盡!!!!

          posted on 2008-12-30 02:23 anyStar 閱讀(1788) 評(píng)論(8)  編輯  收藏

          評(píng)論

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

          換個(gè) 表名  回復(fù)  更多評(píng)論   

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

          和你一樣的問(wèn)題,不知道你能發(fā)下你的QQ么我加您,互相學(xué)習(xí)下.
          看來(lái)我們都在看,勇哥的視頻.  回復(fù)  更多評(píng)論   

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

          我也是一樣的問(wèn)題 頭很大  回復(fù)  更多評(píng)論   

          # re: hibernate新手求助!![未登錄](méi) 2009-03-20 22:59 yang

          我現(xiàn)在也在看王勇老師的視頻,我QQ269676751,大家一起學(xué)習(xí)啊  回復(fù)  更多評(píng)論   

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

          我也遇到了類似的問(wèn)題,剛開(kāi)始時(shí)還可以運(yùn)行,可是我把Mysql重裝了下就不行了,提示錯(cuò)誤是
          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)
          不知道怎么弄了!  回復(fù)  更多評(píng)論   

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

          我的問(wèn)題解決了呢!我看了一下你的配置文件,
          <property name="hibernate.connection.url ">jdbc:mysql:///localhost/hibernate_first</property>改成
          <property name="hibernate.connection.url ">jdbc:mysql://localhost/hibernate_first</property>試試,還有就是你的mysql的用戶名和密碼一下要正確哦!
            回復(fù)  更多評(píng)論   

          # re: hibernate新手求助!![未登錄](méi) 2009-12-07 22:16 ice

          same problem we meet!  回復(fù)  更多評(píng)論   

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

          @222
          hi,我也遇到這個(gè)問(wèn)題,能加我qq么,296291859,以后多多向你請(qǐng)教。請(qǐng)問(wèn)最后怎么解決呢···我也在看王勇老師的視頻··  回復(fù)  更多評(píng)論   


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          <2011年9月>
          28293031123
          45678910
          11121314151617
          18192021222324
          2526272829301
          2345678

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(2)

          隨筆分類

          隨筆檔案

          文章檔案

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 长宁区| 峨边| 和龙市| 隆尧县| 尚志市| 慈溪市| 噶尔县| 绵阳市| 界首市| 东丰县| 汉寿县| 柳林县| 中阳县| 安义县| 星子县| 望江县| 广丰县| 新乡县| 邯郸县| 丰原市| 隆子县| 奎屯市| 巴林左旗| 临洮县| 仁怀市| 启东市| 读书| 汨罗市| 吴江市| 上思县| 清水河县| 同仁县| 乌海市| 自治县| 石楼县| 河源市| 宜宾县| 绥德县| 兴安盟| 虹口区| 涟水县|