hibernate和oracle10g 的问题,大家帮忙看下,谢谢

kevin21232123 2008-04-22 07:41:37
小弟在用hibernate自带的SchemaExport 生成表时,出错,目前还没差出来,用的是Hibernate 3.2.6 oracle10.20 jdk5.0
驱动都加进去了,请高手帮忙看下,我在网上也没找到具体的原因,小弟实在没分了,请见谅,以后不上,谢谢

错误信息:
19:30:07,640 INFO Environment:514 - Hibernate 3.2.6
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.hibernate.cfg.Configuration.reset(Configuration.java:174)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:193)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:197)
at com.dvnchina.boss.ExportDB.main(ExportDB.java:14)
Caused by: java.lang.NullPointerException
at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:144)
at org.hibernate.cfg.Environment.<clinit>(Environment.java:529)
... 4 more


配置文件及源码在下:
hibernate.hbm.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:oracle:thin:@localhost:1521:orcl
</property>
<property name="hibernate.connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>
<property name="hibernate.connection.username">scott</property>
<property name="hibernate.connection.password">tiger</property>
<property name="dialect">
org.hibernate.dialect.Oracle9Dialect
</property>
<property name="show_sql">true</property>
<mapping resource="com/dvnchina/boss/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>


User.hbm.xml:
<?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.dvnchina.boss.User" table="t_user">
<id name="id">
<generator class="uuid"></generator>
</id>
<property name="username"></property>
<property name="password"></property>
<property name="age"></property>
<property name="address"></property>
</class>
</hibernate-mapping>

ExportDB.java

public class ExportDB {

public static void main(String[] args) {

//读取配置文件
Configuration cfg = new Configuration().configure();

//创建SchemaExport对象
SchemaExport export = new SchemaExport(cfg);

//创建数据库表
export.create(true,true);
}

}

...全文
147 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
kevin21232123 2008-04-22
  • 打赏
  • 举报
回复
大家看下了,我自己先顶下了

67,538

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧