Forum Discussion

Andreas's avatar
Andreas
New Contributor
17 years ago

Insert a character stream into a CLOB column data (Oracle 9.x)

Hi,

to store the response (22534 bytes) of a soap request in the database into a CLOB column I used the following code in my groovy script:

// get the request object
def request = testRunner.testCase.testSteps["REQUEST"].testRequest

// get the actual messages
def requestContent = request.requestContent
def responseContent = request.response.contentAsString

// Update der Tabelle log um den Request
sql.executeUpdate("Update log set REQUEST = $requestContent where TRANSACTION_ID = $TRANSACTION_ID_NEW")

// Update der Tabelle log um den Request
sql.executeUpdate("Update log set RESPONSE = $responseContent where TRANSACTION_ID = $TRANSACTION_ID_NEW")

In this case an error rises:
Mon Apr 14 09:54:11 CEST 2008:ERROR:java.sql.SQLException: Datengröße größer als max. Größe für diesen Typ: 22534

This means that the string "responseContent" is too long.

So I used the following code:

Connection theCon = DriverManager.getConnection( database );
theStatement = theCon.prepareStatement ("Update log set RESPONSE = ? where TRANSACTION_ID = ?");
theStatement.setString(2, TRANSACTION_ID_NEW);

byte[] charDataBytes = responseContent.getBytes("UTF-8");
java.io.ByteArrayInputStream byteStream =  new java.io.ByteArrayInputStream (charDataBytes);
theStatement.setAsciiStream(1, byteStream, byteStream.available());
rs = theStatement.executeUpdate();

With this code no error rises but the column RESPONSE in table log remains empty.

I hope you have an idea, thanks
Andreas

2 Replies

  • Andreas's avatar
    Andreas
    New Contributor
    Hi Ole,

    the problem was the installed driver Oracle JDBC Driver version - 9.0.2.0.0. Updated odbc14.jar for Oracle JDBC Driver version - 10.1.0.5.0 and it works fine
    Thanks for your help.

    regards!
    Andreas