2008年8月11日

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 @ 2008-12-30 02:23 anyStar 阅读(1768) | 评论 (8)编辑 收藏

为什么我的myeclipse没有创建Hibernate Mapping File的选项?

如题,我装的是6.5的

posted @ 2008-10-14 21:32 anyStar 阅读(1598) | 评论 (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 阅读(1638) | 评论 (3)编辑 收藏

運行servlet為什么總提示找不到文件

我在Tomcat中文件路徑配置如下:webapps\servlet\WEB-INF\classes

目錄下有一個TestServlet.class文件


web.xml文件配置如下:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
          http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
           version="2.4">
  <servlet>
    <servlet-name>TestServlet</servlet-name>
    <servlet-class>servlet.TestServlet</servlet-class>      
  </servlet>
  <servlet-mapping>
    <servlet-name>TestServlet</servlet-name>
    <url-pattern>/TestServlet</url-pattern>
  </servlet-mapping>
</web-app>


本人愚昧,整了將近一個小時仍然沒搞定,希望高手幫助一下

 

posted @ 2008-08-11 17:33 anyStar 阅读(1590) | 评论 (4)编辑 收藏

<2008年8月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456

导航

统计

常用链接

留言簿(2)

随笔分类

随笔档案

文章档案

搜索

最新评论

阅读排行榜

评论排行榜