Skip to content

prepareMethod=prepare causes DB error code 8179 #1880

@otbutz

Description

@otbutz

Driver version

11.1.1.jre17-preview

SQL Server version

Microsoft SQL Server 2019 (RTM-CU16-GDR) (KB5014353) - 15.0.4236.7 (X64)

Client Operating System

Ubuntu 22.04

JAVA/JVM version

17

Stacktrace (EclipseLink)

Internal Exception: java.sql.BatchUpdateException: Could not find prepared statement with handle 0.
Error Code: 8179
	at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333) ~[?:?]
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeJDK12BatchStatement(DatabaseAccessor.java:939) ~[?:?]
	at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatch(ParameterizedSQLBatchWritingMechanism.java:181) ~[?:?]
	at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatchedStatements(ParameterizedSQLBatchWritingMechanism.java:136) ~[?:?]
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.writesCompleted(DatabaseAccessor.java:1885) ~[?:?]
	at org.eclipse.persistence.internal.sessions.AbstractSession.writesCompleted(AbstractSession.java:4446) ~[?:?]
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.writesCompleted(UnitOfWorkImpl.java:5774) ~[?:?]
	at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.writeChanges(RepeatableWriteUnitOfWork.java:458) ~[?:?]
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:975) ~[?:?]
	... 65 more

Full connection URI: jdbc:sqlserver://mssql-db;databaseName=xxxxx;port=1433;encrypt=true;trustServerCertificate=true;prepareMethod=prepare

Support for prepareMethod was discussed in #1196 and introduced in #1719

Removing the option reverts back to sp_prepexc based execution which seems to fix the issue.

Maybe the prepared statement needs to be recreated at some point?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions