Describe the bug I'm using the JdbcOAuth2AuthorizedClientService with the MariaDB java connector. Authorization fails with a SQLSyntaxErrorException:

Can only convert a byte[] to BINARY, VARBINARY or LONGVARBINARY

To Reproduce Use the JdbcOAuth2AuthorizedClientService with the MariaDB java connector.

Expected behavior No exception should be thrown.

The problem is these two lines:

parameters.add(new SqlParameterValue(Types.BLOB, accessToken.getTokenValue().getBytes(StandardCharsets.UTF_8)));

parameters.add(new SqlParameterValue(Types.BLOB, refreshTokenValue));

According to the JDBC specification, a driver has to implement conversions between byte[] <=> BINARY, VARBINARY, LONGVARBINARY and java.sql.Blob <=> BLOB. While some drivers implement a conversion between byte[] and BLOB, it's a non-standard behaviour and you can't rely on it.

So, in this case, the byte[]s should be wrapped in an appropriate java.sql.Blob type.

Comment From: jgrandja

@queueseven Please see this comment and this one. You need to provide a custom configuration of JdbcOAuth2AuthorizedClientService.

I'm going to close this as a duplicate.