Get the App
SLTechnology News&Howtos  ›  Database  › 

The class12 driver of oracle does not realize the storage of clob or blob by jdbc, the solution

Shulou Source: shulou.com Published: 2022-06-01 10:20:07 09月25日 Update

An exception occurs when using native jdbc to save large field clob or blob:

ERROR [pool-12-thread-1] PartitionConsumerThread.run (128C) | java.lang.AbstractMethodError: Method oraclebc/driver/T4CPreparedStatement.setCharacterStream (ILjava/io/Reader;J) V is abstract

Analyze the reasons:

The exception means that the T4CPreparedStatement class calls an abstract method, meaning that it does not implement jdbc's setCharacterStream itself. The database driver used in our framework uses oracle.sql.class12. After storing an exception in a large field, I went to see the source code of T4CPreparedStatement. He inherited the implementation of setCharacterStream,setClob and setBlob methods in OraclePreparedStatement. There are implementations of setCharacterStream,setClob and setBlob methods in OraclePreparedStatement, but the parameter types of jdbc's setCharacterStream,setClob and setBlob methods are different. You can take a look at the source code, meaning that neither OraclePreparedStatement nor T4CPreparedStatement implements the setCharacterStream,setClob and setBlob methods of jdbc. It only inherits the abstract method, so we will report the previous exception when we call it. The solution: change the oracle driver, and then I change the driver to odjbc6. I also looked at the source code and found that OraclePreparedStatement has an implementation of jdbc's PrepareStatement method to deal with large fields, which perfectly solves the problem.

Tags: Method driver field source code meaning method storage reason parameter just that is data database framework type problem report analysis processing Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Information Xiaomi NVidia Shulou Tech Info