GitHub user GutoVeronezi closed the discussion with a comment: An error getting 
clusters resources information on GUI ACS 4.22

Hello guys,

Just for completeness of the information:

Inside method `TransactionLegacy#prepareAutoCloseStatement`, the method 
`TransactionLegacy#closePreviousStatement` is called. Therefore, when making 
two consecutive calls of method `TransactionLegacy#prepareAutoCloseStatement`, 
the first statement is closed before it is executed, resulting in the observed 
situation. HikariCP and DBCP have different workflows to close statements. When 
using HikariCP, it enables statement caching (only supported by the MySQL JDBC 
driver) and has a workflow that allows the first statement to still work after 
being "closed" by the consecutive method call. However, DBCP closes the 
statement right away. Therefore, when using HikariCP + MariaDB, DBCP + MariaDB, 
or DBCP + MySQL, the first statement will always be closed, causing the 
situation. The situation was fixed with PR #12713.

---

> But currently, I'm not really sure on how i can translate my db.cloud.uri 
> from the jdbc:mariadb to jdbc:mysql. Just changing mariadb to mysql in the 
> uri and removing sequential shows 2026-03-03 07:28:36,085 ERROR 
> [c.c.u.d.DbUtil] (main:[]) (logid:) GET_LOCK() throws exception 
> java.sql.SQLException: Operation not allowed for a result set of type 
> ResultSet.TYPE_FORWARD_ONLY.

@zergawcloud, regarding this exception, it occurs because 
`scrollTolerantForwardOnly` flag is not being set. PR #8753 updated the MySQL 
JDBC driver dependencies, also changing from version 8.0.19 to version 8.0.33. 
In version [8.0.20], a change was made to correct a bug with a `ResultSet` 
configuration:

```
When creating a Statement, the specification of the resultSetType parameter was 
not respected, so the ResultSet type was always defined as 
ResultSet.TYPE_FORWARD_ONLY. With this correction, the resultSetType parameter 
is now respected. Furthermore, type validation was added so that calling the 
beforeFirst, afterLast, first, last, absolute, relative, or previous methods 
will result in an exception if the ResultSet type is 
ResultSet.TYPE_FORWARD_ONLY. (Error #30474158)
```

In version [8.0.24], the [scrollTolerantForwardOnly] property was implemented 
for backward compatibility:

```
A new connection property, scrollTolerantForwardOnly, was introduced, 
preserving the inherited behavior from Connector/J 8.0.17 and earlier, 
tolerating backward and absolute cursor movements in result sets of type 
ResultSet.TYPE_FORWARD_ONLY. This serves to maintain compatibility with legacy 
code that leveraged the old behavior. See the scrollTolerantForwardOnly 
description for details. (Error #31747910)
```

PR #8753 added this flag hardcoded when using the standard parameters; however, 
when using the custom URI settings, it is necessary to add the flag 
[scrollTolerantForwardOnly] as true to the URI for the connection to work 
properly. I have never validated failover/HA with the MySQL driver, though.

[8.0.20]: https://dev.mysql.com/doc/relnotes/connector-j/en/news-8-0-20.html
[8.0.24]: https://dev.mysql.com/doc/relnotes/connector-j/en/news-8-0-24.html
[scrollTolerantForwardOnly]: 
https://dev.mysql.com/doc/connector-j/en/connector-j-connp-props-result-sets.html

GitHub link: 
https://github.com/apache/cloudstack/discussions/12498#discussioncomment-16017199

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to