hibernate 连接数据库报错 获取xml失败 求大佬帮忙看一下

这是 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">

<session-factory>

    <property name="connection.url">jdbc:oracle:thin:@localhost:1521:ORCL</property>
    <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
    <property name="connection.username">Reust</property>
    <property name="connection.password">kingstar</property>

    <property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
    <property name="show_sql">true</property>
    <property name="format_sql">true</property>
    <property name="hbm2ddl.auto">update</property><!-- create -->


    <mapping resource="cd/entity/Igendpd.hbm.xml"/>
    <mapping resource="cd/entity/Iguser.hbm.xml"/>


</session-factory>

这是hbm.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">


<!-- schema="数据库对象集合名称" --><!-- dynamic-update="true" --><!-- select-before-update="true" -->



SEQ_IG_END_PD





性别

</class>

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<!-- schema="数据库对象集合名称" --><!-- dynamic-update="true" --><!-- select-before-update="true" -->



SEQ_IG_USER





真实姓名

    <property name="iglogName" type="string">
        <column name="ig_log_name">
            <comment>登陆姓名</comment>
        </column>
    </property>
    <property name="igAge" type="Integer">
        <column name="ig_age">
            <comment>年龄</comment>
        </column>
    </property>
    <property name="igendID" type="Integer">
        <column name="ig_end_id">
            <comment>性别ID</comment>
        </column>
    </property>
    <property name="igPwassd" type="string">
        <column name="ig_pwassd">
            <comment>密码</comment>
        </column>
    </property>

</class>

这是 Configuration conf = new Configuration().configure(); 获取seesion 并测试**

package meg;

import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import cd.dao.ResultDao;
import cd.entity.Iguser;

public class Test {

// 会话工厂
protected static SessionFactory sessionFactory = null;

// 绑定到线程的集合
protected static ThreadLocal<Session> sessionThreadLocal = new ThreadLocal<Session>();


public static Session getSession() {
    Session session = null;
    if (sessionThreadLocal != null) {
        session = sessionThreadLocal.get();
    }
    if (session == null) {
        if (sessionFactory == null) {
            Configuration conf = new Configuration();
            conf.configure();
            sessionFactory = conf.buildSessionFactory();
        }
        session = sessionFactory.openSession();
        if (sessionThreadLocal == null) {
            sessionThreadLocal = new ThreadLocal<Session>();
        }
        sessionThreadLocal.set(session);
    }
    return session;
}

public static void main(String[] args) {
    Test ts=new Test();
    ts.getSession();
    System.out.print("连接成功");

}

}

**
最后这是报错啊 **

2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration boolean -> org.hibernate.type.BooleanType@ba2e48
2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration boolean -> org.hibernate.type.BooleanType@ba2e48
2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.Boolean -> org.hibernate.type.BooleanType@ba2e48
2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration numeric_boolean -> org.hibernate.type.NumericBooleanType@130c8e9
2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration true_false -> org.hibernate.type.TrueFalseType@9ed91f
2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration yes_no -> org.hibernate.type.YesNoType@11a59ce
2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration byte -> org.hibernate.type.ByteType@85a863
2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration byte -> org.hibernate.type.ByteType@85a863
2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.Byte -> org.hibernate.type.ByteType@85a863
2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration character -> org.hibernate.type.CharacterType@33aa9b
2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration char -> org.hibernate.type.CharacterType@33aa9b
2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.Character -> org.hibernate.type.CharacterType@33aa9b
2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration short -> org.hibernate.type.ShortType@1f920cf
2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration short -> org.hibernate.type.ShortType@1f920cf
2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.Short -> org.hibernate.type.ShortType@1f920cf
2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration integer -> org.hibernate.type.IntegerType@1773a14
2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration int -> org.hibernate.type.IntegerType@1773a14
2018-11-14 17:35:44,433 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.Integer -> org.hibernate.type.IntegerType@1773a14
2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration long -> org.hibernate.type.LongType@a5ce92
2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration long -> org.hibernate.type.LongType@a5ce92
2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.Long -> org.hibernate.type.LongType@a5ce92
2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration float -> org.hibernate.type.FloatType@1bfefb
2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration float -> org.hibernate.type.FloatType@1bfefb
2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.Float -> org.hibernate.type.FloatType@1bfefb
2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration double -> org.hibernate.type.DoubleType@5c18ff
2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration double -> org.hibernate.type.DoubleType@5c18ff
2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.Double -> org.hibernate.type.DoubleType@5c18ff
2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration big_decimal -> org.hibernate.type.BigDecimalType@ae4f8b
2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.math.BigDecimal -> org.hibernate.type.BigDecimalType@ae4f8b
2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration big_integer -> org.hibernate.type.BigIntegerType@3d12a6
2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.math.BigInteger -> org.hibernate.type.BigIntegerType@3d12a6
2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration string -> org.hibernate.type.StringType@e8f27e
2018-11-14 17:35:44,443 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.String -> org.hibernate.type.StringType@e8f27e
2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration url -> org.hibernate.type.UrlType@113e371
2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.net.URL -> org.hibernate.type.UrlType@113e371
2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration date -> org.hibernate.type.DateType@93886b
2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.sql.Date -> org.hibernate.type.DateType@93886b
2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration time -> org.hibernate.type.TimeType@3c0737
2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.sql.Time -> org.hibernate.type.TimeType@3c0737
2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration timestamp -> org.hibernate.type.TimestampType@9da1dd
2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.sql.Timestamp -> org.hibernate.type.TimestampType@9da1dd
2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.util.Date -> org.hibernate.type.TimestampType@9da1dd
2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration dbtimestamp -> org.hibernate.type.DbTimestampType@9db0ad
2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration calendar -> org.hibernate.type.CalendarType@1644028
2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.util.Calendar -> org.hibernate.type.CalendarType@1644028
2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.util.GregorianCalendar -> org.hibernate.type.CalendarType@1644028
2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration calendar_date -> org.hibernate.type.CalendarDateType@15268d7
2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration locale -> org.hibernate.type.LocaleType@b0a518
2018-11-14 17:35:44,453 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.util.Locale -> org.hibernate.type.LocaleType@b0a518
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration currency -> org.hibernate.type.CurrencyType@1313e0e
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.util.Currency -> org.hibernate.type.CurrencyType@1313e0e
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration timezone -> org.hibernate.type.TimeZoneType@2a2ae9
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.util.TimeZone -> org.hibernate.type.TimeZoneType@2a2ae9
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration class -> org.hibernate.type.ClassType@d4a1d3
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.lang.Class -> org.hibernate.type.ClassType@d4a1d3
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration uuid-binary -> org.hibernate.type.UUIDBinaryType@7f1228
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.util.UUID -> org.hibernate.type.UUIDBinaryType@7f1228
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration uuid-char -> org.hibernate.type.UUIDCharType@d200d8
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration pg-uuid -> org.hibernate.type.PostgresUUIDType@1f854bd
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration binary -> org.hibernate.type.BinaryType@1672313
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration byte[] -> org.hibernate.type.BinaryType@1672313
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration [B -> org.hibernate.type.BinaryType@1672313
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration wrapper-binary -> org.hibernate.type.WrapperBinaryType@1542cdc
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration Byte[] -> org.hibernate.type.WrapperBinaryType@1542cdc
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration [Ljava.lang.Byte; -> org.hibernate.type.WrapperBinaryType@1542cdc
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration image -> org.hibernate.type.ImageType@c2060e
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration characters -> org.hibernate.type.CharArrayType@75d174
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration char[] -> org.hibernate.type.CharArrayType@75d174
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration [C -> org.hibernate.type.CharArrayType@75d174
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration wrapper-characters -> org.hibernate.type.CharacterArrayType@13638d4
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration [Ljava.lang.Character; -> org.hibernate.type.CharacterArrayType@13638d4
2018-11-14 17:35:44,463 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration Character[] -> org.hibernate.type.CharacterArrayType@13638d4
2018-11-14 17:35:44,473 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration text -> org.hibernate.type.TextType@1b271f1
2018-11-14 17:35:44,473 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration blob -> org.hibernate.type.BlobType@5f00f9
2018-11-14 17:35:44,473 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.sql.Blob -> org.hibernate.type.BlobType@5f00f9
2018-11-14 17:35:44,473 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration materialized_blob -> org.hibernate.type.MaterializedBlobType@1535ac
2018-11-14 17:35:44,473 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration wrapper_materialized_blob -> org.hibernate.type.WrappedMaterializedBlobType@293b53
2018-11-14 17:35:44,473 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration clob -> org.hibernate.type.ClobType@101f287
2018-11-14 17:35:44,473 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration java.sql.Clob -> org.hibernate.type.ClobType@101f287
2018-11-14 17:35:44,473 DEBUG [org.hibernate.type.BasicTypeRegistry] - Adding type registration materialized_clob -> org.hibernate.type.MaterializedClobType@d8f55c
Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE
at org.hibernate.type.BasicTypeRegistry.(BasicTypeRegistry.java:94)
at org.hibernate.type.TypeResolver.(TypeResolver.java:59)
at org.hibernate.cfg.Configuration.(Configuration.java:250)
at org.hibernate.cfg.Configuration.(Configuration.java:302)
at meg.Test.getSession(Test.java:30)
at meg.Test.main(Test.java:45)

我直接写测试方法是能测试通的 但是写成hibernate.cfg.xml就不行了 下面是我直接在java中写的

            public static void main(String[] args) {
     Connection con;//声明Connection对象
     Statement sql;
     ResultSet res ;
     try {
            Class.forName("oracle.jdbc.driver.OracleDriver");//加载数据库驱动
        //  System.out.print("加载数据库驱动成功");

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

         try {
             con=DriverManager.getConnection("jdbc:oracle:" + "thin:@127.0.0.1:1521:ORCL","Reust","kingstar");
            // System.out.print("数据库连接成功");

        } catch (SQLException e) {
            // TODO: handle exception
            e.printStackTrace();
        }

}
}

3个回答

这个问题已尽处理了 是我引用过多的包了。现在有有一个问题。就是我查用户表。返回一直是空 有点懵逼 求大神帮助一下

按你说法,表里应该有数据,而且java应该没抛出异常,那个表有数据权限没?会不会是数据权限没设置,因此取回空数据

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问