在TypeHandler应用程序中,我有一个,它为调用Oracle的存储过程所需的STRUCTS数组填充数据。blob条目在存储过程中被正确填充并可见;字符串条目没有,也没有发送字符串数据。日志中没有错误或警告。数据在应用程序中不是空的和有效的。数据只是在应用程序和oracle之间消失。
我的处理程序的setParameter实现如下所示:
public void setParameter(PreparedStatement ps, int i, List<MailAttachment> parameter,
JdbcType jdbcType) throws SQLException
{
List<MailAttachment> attachmentList = parameter;
OracleConnection oracleConnection = ps.getConnection().unwrap(OracleConnection.class);
StructDescriptor structDescriptor = StructDescriptor.createDescriptor(ATTACHMENT, oracleConnection);
Object[] structs = null;
structs = new Object[attachmentList == null ? 0 :attachmentList.size()];
if (attachmentList != null) {
//CharacterSet chs = CharacterSet.make(CharacterSet.UTF8_CHARSET);
for (int index = 0; index < attachmentList.size(); index++) {
MailAttachment mailAttachment = attachmentList.get(index);
BLOB blob = null;
if (mailAttachment.getData() != null){
blob = BLOB.createTemporary(oracleConnection,false,BLOB.DURATION_SESSION);
// filling blob works
}
CHAR attachName = new CHAR(mailAttachment.getFilename(), CharacterSet.make(CharacterSet.UTF8_CHARSET) );
CHAR contentType = new CHAR(mailAttachment.getContentType(), CharacterSet.make(CharacterSet.UTF8_CHARSET) );
STRUCT struct = new STRUCT(structDescriptor, oracleConnection,
new Object[] {blob, attachName, contentType, null}
);
structs[index] = struct;
}
}
ArrayDescriptor arrayDesc = ArrayDescriptor.createDescriptor(ATTACHMENT_LIST, oracleConnection);
ARRAY oracleArray = new ARRAY(arrayDesc, oracleConnection, structs);
ps.setObject(i, oracleArray);
}发布于 2016-08-19 09:22:15
此问题与Oracle JDBC驱动程序及其对国际化的支持有关。
记住,在ojdbc文件的正确版本的classpath/pom文件中包含orai18n.jar。
如果orai18n.jar丢失了:
https://stackoverflow.com/questions/39035050
复制相似问题