0

Java class creates a prepared statement and binds value MS-SQL is the data store used

Jars Used

  • jdbi3-core-3.8.2
  • HikariCP: 3.4.1
  • mssql-jdbc:7.2.2.jre8
DECLARE @status VARCHAR(max)
DECLARE @destination VARCHAR(max) = 'xyz'
DECLARE @attributes_var NVARCHAR(max)
-- status , current_destination , container_id
UPDATE dbo.container_master
SET @status= status, status = 'DELETED', @destination= current_destination , current_destination = null , @attributes_var = JSON_QUERY(attributes , '$')
WHERE container_id = 'cont_id'
--   current_destination ,
SELECT count(container_id) AS count
FROM dbo.container_master
     CROSS APPLY OPENJSON (attributes ) WITH (value NVARCHAR(100) '$')
where current_destination = @destination
and status <> 'DELETED'
AND attributes = JSON_QUERY(@attributes_var, '$')

Count Query when executed Returns No Rows , ResultSet is null Throwing a Non-TransientExecption

Query statement = handle.createQuery(query);
this.bindParameters(statement, queryParameters);
ResultBearing queryResults = (ResultBearing)statement.execute(ResultProducers.returningResults());
results = (List)queryResults.map(this.mapMapper).stream().map(this::toBytes).collect(Collectors.toList());

Last Line Throws a NonTransient Exception

Options Tried When Only a simple select queries are executed it works

Things Working Update Fired. Query executed successfully

Issue Handling of ResultSets

vivek
  • 1
  • 1
    Aside... JDBC 7.2.2 was released [back in 2019](https://learn.microsoft.com/en-us/sql/connect/jdbc/release-notes-for-the-jdbc-driver#-722). Is there a particular reason you're not using the [current JDBC 10.2 driver](https://learn.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server) that also supports JDK 1.8? – AlwaysLearning Apr 19 '22 at 10:13
  • Your SQL returns two sets of row counts: the first for the update statement, the second for the select statement. Have you considered surrounding your update statement with `set nocount on; ...; set nocount off;`? – AlwaysLearning Apr 19 '22 at 10:15

0 Answers0