Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Add Codec for java.sql.Timestamp #151

Closed
papahigh opened this issue Nov 26, 2020 · 4 comments
Closed

Add Codec for java.sql.Timestamp #151

papahigh opened this issue Nov 26, 2020 · 4 comments

Comments

@papahigh
Copy link

Hi,

I'm getting the following error Cannot encode value of type 'class java.sql.Timestamp' for a java.sql.Timestamp value.
Could you please add a codec for this case?

Thanks

@mp911de
Copy link
Contributor

mp911de commented Nov 26, 2020

R2DBC isn't affiliated with java.sql at all. There's no need to pull in the JDBC module. Also, from a Java modules perspective, depending on JDBC sends the wrong signals. R2DBC embraces JSR-310 types which are a way better fit than the broken JDBC types where timezones contribute to additional confusion.

@papahigh
Copy link
Author

@mp911de Hi Mark!
I'm trying r2dbc-mysql with micronaut-r2dbc.
And looks like micronaut converts any date-related class to java.sql.Timestamp. (I'm using java.time classes).
Because of the missing codec, I got runtime exceptions.

Please take a look at PR #152. I added codecs for java.sql.Timestamp as well as for java.util.Date which is a superclass for legacy dates. With this change, everything works fine.

@mp911de
Copy link
Contributor

mp911de commented Nov 26, 2020

Then using JDBC types with R2DBC is a shortcoming of Micronaut that should be fixed in Micronaut instead of introducing unwanted dependencies here.

R2DBC is a specification. There exist several implementations and each one is exactly following the spec. If a single driver compensates for the invalid usage of Micronaut, the it makes this driver work. Yet the other drivers won't work when used with Micronaut.

@papahigh
Copy link
Author

@mp911de Thanks, I'll open a PR in micronaut then.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants