2008年9月18日

          hibernate新手求助?。?/a>

          今天下午學習使用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>

          下面是連接數(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);
           }

          }


          希望路過高手不吝指導一下,感激不盡!?。。?

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

          為什么我的myeclipse沒有創(chuàng)建Hibernate Mapping File的選項?

          如題,我裝的是6.5的

          posted @ 2008-10-14 21:32 anyStar 閱讀(1610) | 評論 (2)編輯 收藏

          jstl的配置

          1.到http://archive.apache.org/dist/jakarta/taglibs/standard/binaries/下載你所需的版本

          2.將jstl.jar和standard.jar拷貝到WEB-INF目錄下的lib文件里

          3.在WEB-INF目錄下新建一個tlds文件夾,將c.tld和c-rt.tld考進去

          4.在web.xml文件配置你所用到的標簽如下:

          <?xml version="1.0" encoding="UTF-8"?>
          <web-app version="2.5"
           xmlns="http://java.sun.com/xml/ns/javaee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
           http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
           
          <taglib>
              <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
              <taglib-location>/WEB-INF/tlds/c.tld</taglib-location>
          </taglib>

          <taglib>
              <taglib-uri>http://java.sun.com/jstl/core-rt</taglib-uri>
              <taglib-location>/WEB-INF/tlds/c-rt.tld</taglib-location>
          </taglib>

          ........................
          </web-app>

           

          posted @ 2008-09-18 20:30 anyStar 閱讀(1655) | 評論 (3)編輯 收藏

          <2008年9月>
          31123456
          78910111213
          14151617181920
          21222324252627
          2829301234
          567891011

          導航

          統(tǒng)計

          常用鏈接

          留言簿(2)

          隨筆分類

          隨筆檔案

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 界首市| 徐汇区| 修武县| 东源县| 安国市| 英山县| 普宁市| 安溪县| 内丘县| 工布江达县| 凤台县| 尉犁县| 德化县| 勐海县| 新绛县| 明水县| 桓台县| 洱源县| 元谋县| 都江堰市| 布尔津县| 靖江市| 团风县| 上虞市| 灵丘县| 南宫市| 曲麻莱县| 马尔康县| 望江县| 南郑县| 宜兴市| 深水埗区| 阳春市| 苗栗市| 石狮市| 年辖:市辖区| 鹤山市| 东乌| 车致| 齐齐哈尔市| 正阳县|