在eclipse环境下使用oracle做hibernate链接出现问题
写的hibernate.cfg.xml文件如下:<?xmlversion="1.0"encoding="UTF-8"?><!DOCTYPEhibernate-config...
写的hibernate.cfg.xml文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="test">
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.password">ix36</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>
<property name="connection.username">ix36</property>
<property name="default_schema">ix36</property>
<property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="show_sql">true</property>
<mapping resource="test"/>
</session-factory>
</hibernate-configuration>
相应的调用类如下:
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
Configuration cfg=new Configuration();
SchemaExport export = new SchemaExport(cfg);
export.create(true, true);
}catch(HibernateException e){
e.printStackTrace();
}
}
但是运行后出现错误信息如下:
log4j:WARN No appenders could be found for logger (org.hibernate.type.BasicTypeRegistry).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
org.hibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.
at org.hibernate.dialect.Dialect.instantiateDialect(Dialect.java:191)
at org.hibernate.dialect.Dialect.getDialect(Dialect.java:169)
at org.hibernate.dialect.Dialect.getDialect(Dialect.java:184)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:123)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:92)
at testBook.DoFirst.main(DoFirst.java:16)
想让大家帮忙看看是不是哪里配错了,还是少什么包,谢谢了。 展开
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="test">
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.password">ix36</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>
<property name="connection.username">ix36</property>
<property name="default_schema">ix36</property>
<property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="show_sql">true</property>
<mapping resource="test"/>
</session-factory>
</hibernate-configuration>
相应的调用类如下:
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
Configuration cfg=new Configuration();
SchemaExport export = new SchemaExport(cfg);
export.create(true, true);
}catch(HibernateException e){
e.printStackTrace();
}
}
但是运行后出现错误信息如下:
log4j:WARN No appenders could be found for logger (org.hibernate.type.BasicTypeRegistry).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
org.hibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.
at org.hibernate.dialect.Dialect.instantiateDialect(Dialect.java:191)
at org.hibernate.dialect.Dialect.getDialect(Dialect.java:169)
at org.hibernate.dialect.Dialect.getDialect(Dialect.java:184)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:123)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:92)
at testBook.DoFirst.main(DoFirst.java:16)
想让大家帮忙看看是不是哪里配错了,还是少什么包,谢谢了。 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询