Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQLException: protocol violation [14,114,] with specific nclob value

1553843Apr 29 2014 — edited Oct 15 2014

please see attached test code and test data. with the given test data, JDBC throws protocol violation.

Server version, where this was found first: 11.2.0.4

fails with ojdbc7 version 12.1.0.1.0

fails with ojdbc6 version 12.1.0.1.0

works with ojdbc6 version 11.2.0.4

any hints/comments?

thanks in advance.

Exception:

java.sql.SQLException: Protocol violation: [ 14, 114, ]

at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:669)

at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:249)

at oracle.jdbc.driver.T4C8TTIClob.read(T4C8TTIClob.java:245)

at oracle.jdbc.driver.T4CConnection.getChars(T4CConnection.java:3901)

at oracle.sql.CLOB.getChars(CLOB.java:517)

at oracle.sql.CLOB.getSubString(CLOB.java:354)

at oracle.jdbc.driver.ClobAccessor.getString(ClobAccessor.java:454)

at oracle.jdbc.driver.GeneratedStatement.getString(GeneratedStatement.java:327)

at oracle.jdbc.driver.GeneratedScrollableResultSet.getString(GeneratedScrollableResultSet.java:882)

at OracleProtocolViolation.test(OracleProtocolViolation.java:43)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)

at org.junit.runners.ParentRunner.run(ParentRunner.java:309)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Test code to reproduce:

import static org.junit.Assert.assertEquals;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import oracle.jdbc.pool.OracleDataSource;

import org.junit.Test;

public class OracleProtocolViolation {

  @Test

  public void test() throws SQLException {

    String url = "jdbc:oracle:thin:@<host>:1521:orcl";

    OracleDataSource oracleDataSource = new OracleDataSource();

    oracleDataSource.setURL(url);

    oracleDataSource.setUser("USER");

    oracleDataSource.setPassword("PASSWORD");

    Connection connection = oracleDataSource.getConnection();

    try (Statement stmt = connection.createStatement()) {

      try {

      stmt.execute("CREATE TABLE TABLE1 ( COLUMN1 NCLOB )");

      } catch (SQLException e) {

        stmt.execute("DELETE FROM TABLE1");

      }

    }

    String text = "<p><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><span><strong>Testziel:</strong></span></span></p><p><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><span></span><span style=\"font-family: 'Tahoma','sans-serif'; background: #fcfcfc; font-size: 8.5pt\">Schaltfl&auml;che </span><span>Auskunft - Zahldaten - Noch nicht ausgezahlte Kleinbetr&auml;ge anzeigen</span><span style=\"font-family: 'Tahoma','sans-serif'; background: #fcfcfc; font-size: 8.5pt\">... aktiv</span><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"></span><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><strong> </strong></span></span></p><p><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"></span><span><strong>Beschreibung:</strong></span></span></p><p><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><span></span><span style=\"font-family: 'Tahoma','sans-serif'; background: #fcfcfc; font-size: 8.5pt\">vorliegende Benutzerberechtigung -&gt; Feststellen</span></span></p><p><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><span style=\"font-family: 'Tahoma','sans-serif'; background: #fcfcfc; font-size: 8.5pt\"></span></span><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><span style=\"font-family: 'Tahoma','sans-serif'; background: #fcfcfc; font-size: 8.5pt\"></span></span><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><span style=\"font-family: 'Tahoma','sans-serif'; background: #fcfcfc; font-size: 8.5pt\"></span><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"></span><span style=\"font-family: 'Tahoma','sans-serif'; background: #fcfcfc; font-size: 8.5pt\">Schaltfl&auml;che ist aktiv</span><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"></span><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><strong> </strong></span></span></p><p><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"></span><span><strong>Vorbedingungen</strong></span></span><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><span><strong>:</strong></span></span></p><p><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><span></span><span style=\"font-family: 'Tahoma','sans-serif'; background: #fcfcfc; font-size: 8.5pt\">Benutzerberechtigung -&gt; Feststellen</span></span></p><p><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><span style=\"font-family: 'Tahoma','sans-serif'; background: #fcfcfc; font-size: 8.5pt\"></span></span><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"></span><span><strong>Durchzuf&uuml;hrende Aktionen:</strong></span></span></p><p><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><span></span><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\">Pr&uuml;fung der Schaltfl&auml;che</span><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><strong> </strong></span></span></p><p><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"></span><span><strong>Erwartetes Ergebnis:</strong></span></span></p><p><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><span></span><span style=\"font-family: 'Tahoma','sans-serif'; background: #fcfcfc; font-size: 8.5pt\">Schaltfl&auml;che ist aktiv</span><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"></span><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><strong> </strong></span></span></p><p><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"></span><span><strong>Nachbedingung:</strong></span></span></p><p><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\"><span></span><span style=\"font-family: 'Tahoma','sans-serif'; font-size: 8.5pt\">keine</span></span></p>";

    try (PreparedStatement stmt = connection.prepareStatement("INSERT INTO TABLE1 (COLUMN1) VALUES (?)")) {

      stmt.setString(1, text);

      int insertedRows = stmt.executeUpdate();

      assertEquals(1, insertedRows);

    }

    try (PreparedStatement stmt = connection.prepareStatement("SELECT * FROM TABLE1")) {

      try (ResultSet rs = stmt.executeQuery()) {

        while (rs.next()) {

          System.out.println(rs.getString(1));

        }

      }

    }

  }

}

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 17 2014
Added on Apr 29 2014
9 comments
1,981 views