Hibernate 运行报错,空指针异常

INFO: HHH000401: using driver [oracle.jdbc.driver.OracleDriver] at URL [jdbc:oracle:thin:@localhost:1521:orcl]

九月 15, 2018 11:39:14 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

INFO: HHH000046: Connection properties: {user=scott, password=****}

Exception in thread "main" java.lang.NullPointerException

at java.lang.String.(String.java:166)

at oracle.sql.CharacterSet.AL32UTF8ToString(CharacterSet.java:1628)

at oracle.jdbc.driver.DBConversion.CharBytesToString(DBConversion.java:834)

at oracle.jdbc.driver.DBConversion.CharBytesToString(DBConversion.java:773)

at oracle.jdbc.driver.T4CTTIoauthenticate.receiveOauth(T4CTTIoauthenticate.java:816)

at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:376)

at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:441)

at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:165)

at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)

at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:839)

at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:204)

at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:242)

at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:117)

at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:85)

at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184)

at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156)

at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1827)

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1785)

at com.util.HibernateUtil.getSessionFactory(HibernateUtil.java:18)

at com.test.Test1.get(Test1.java:61)

at com.test.Test1.main(Test1.java:30)

hibernate.cfg.xml是这样配置的.

<?xml version='1.0' encoding='utf-8'?>

<!DOCTYPE hibernate-configuration PUBLIC

"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<session-factory>

     <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>

      <property name="connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>

     <property name="connection.username">scott</property>

     <property name="connection.password">tiger</property>

      <property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>

     <property name="show_sql">true</property>

</session-factory>

我看其他同学正确的代码,我出的问题是在方言那里就执行不下去了. 哪位大侠可以帮我看一下是什么问题吗

是oracle的字符集安装不好然后导致这部分取不到值? 如果这样的话,要怎么处理呢.

1个回答

你在配置里面试试这些

 ## Oracle

#hibernate.dialect org.hibernate.dialect.Oracle8iDialect
#hibernate.dialect org.hibernate.dialect.Oracle9iDialect
#hibernate.dialect org.hibernate.dialect.Oracle10gDialect
#hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
#hibernate.connection.username ora
#hibernate.connection.password ora
#hibernate.connection.url jdbc:oracle:thin:@localhost:1521:orcl
#hibernate.connection.url jdbc:oracle:thin:@localhost:1522:XE

这是hibernate官方给的oracle配置信息,其它的可以去\hibernate-release-5.3.3.Final\project\etc\hibernate.properties文件中看看

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