2008年12月30日

          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ù)庫的類:

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

          }


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

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

          <2008年12月>
          30123456
          78910111213
          14151617181920
          21222324252627
          28293031123
          45678910

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(2)

          隨筆分類

          隨筆檔案

          文章檔案

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 永宁县| 胶州市| 湘潭县| 福鼎市| 和林格尔县| 额济纳旗| 敦煌市| 云和县| 从化市| 于田县| 塘沽区| 平遥县| 建湖县| 阿尔山市| 湖州市| 潜山县| 福建省| 大洼县| 绥滨县| 寿阳县| 宁夏| 织金县| 眉山市| 阳信县| 万荣县| 陕西省| 崇阳县| 晋州市| 凭祥市| 社会| 南澳县| 新河县| 乐平市| 元阳县| 固安县| 兴国县| 宜城市| 兴仁县| 泸州市| 玉溪市| 隆子县|