2

我正在使用带有 Oracle DB 10g 的 Weblogic 10.3.1 上的 Hibernate 3.3.SP1 + Spring 1.2.6 进行项目。最近,我们将 Hibernate 从 v3.0.5 迁移到 3.3.SP1。尝试插入 LOB(BLOB 或 CLOB)时出现了一个奇怪的错误(以前没有发生过)。我收到以下错误:

189202 [[ACTIVE] ExecuteThread: '10' for queue: 'weblogic.kernel.Default (self-tuning)'] 
     WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: null
189202 [[ACTIVE] ExecuteThread: '10' for queue: 'weblogic.kernel.Default (self-tuning)'] 
     ERROR org.hibernate.util.JDBCExceptionReporter - Pool connect failed : 
     weblogic.common.ResourceException: 
     my.wls.datasource(dtJndiName): 0:
Could not connect to 'oracle.jdbc.OracleDriver'.

返回的消息是:

ORA-01017: invalid username/password; logon denied

It is likely that the login or password is not valid.
It is also possible that something else is invalid in
    the configuration or that the database is not available.

之后,数据源“损坏”,并且在连续 10 次错误连接尝试后,Oracle 锁定了该帐户。

我必须注意到,除了 Weblogic 中预先配置的数据源之外,该应用程序绝对没有连接到数据库的代码。由于应用程序在将 LOB 插入 DB 之前运行良好,因此可以安全地假设数据源已正确配置。

示例映射(我无法发布确切的 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 package="my.model.persist">
    <class name="LobTable" table="LOB_TABLE">
        <id name="id" type="long" column="RS_ID" unsaved-value="null" length="10">
            <generator class="native"></generator>
        </id>   
        <property name="blob1" type="org.springframework.orm.hibernate3.support.BlobByteArrayType" column="BLOB1"></property>
        <property name="blob2" type="org.springframework.orm.hibernate3.support.BlobByteArrayType" column="BLOB2"></property>
    </class>    
</hibernate-mapping>

该代码尝试在三个表中保留一些 LOB 值。尝试保存到第一个时出现错误。如果我删除保存到第一个的代码,则错误会出现在第二个等等。

到目前为止,我发现的唯一解决方案是将数据源连接的初始容量设置为最大连接数(15)。在这种情况下,系统看起来很稳定。然而,这种解决方案是不可接受的,因为我们不了解问题的性质。

我已经在四种不同的环境(Weblogic + Oracle)中尝试过了。错误并不总是以相同的频率出现(在某些系统中,它会在无法插入 LOB 之前工作一段时间)。此外,在调试时,我注意到如果我增加日志输出(我只是在 log4j 中添加了更多调试消息),错误就会停止出现。这让我觉得这可能是 WLS 和 DB 之间的同步问题。

你有什么想法?如果您需要更多说明,请告诉我。


启用 Hibernate 查询输出并将 hbm.xml 更改为将 LOB 作为声明的最后一个字段后的结果仍然是相同的错误:

Hibernate: select hibernate_sequence.nextval from dual
Hibernate: select hibernate_sequence.nextval from dual
Hibernate: insert into LOB_TABLE_1 (field20, field21, field22, field23, field24, field25, field26, field27, field28, field29, field30, field31, LOB_FIELD_3, LOB_FIELD_4, ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into LOB_TABLE_2 (field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, LOB_FIELD_1, LOB_FIELD_2, ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
105039 [[ACTIVE] ExecuteThread: '11' for queue: 'weblogic.kernel.Default (self-tuning)'] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: null
105039 [[ACTIVE] ExecuteThread: '11' for queue: 'weblogic.kernel.Default (self-tuning)'] ERROR org.hibernate.util.JDBCExceptionReporter - Pool connect failed : weblogic.common.ResourceException: 
    my.wls.datasource(dtJndiName): 0:
 Could not connect to 'oracle.jdbc.OracleDriver'.

 The returned message is: ORA-01017: invalid username/password; logon denied

 It is likely that the login or password is not valid.
 It is also possible that something else is invalid in
 the configuration or that the database is not available.
4

0 回答 0