Closed Bharati17 closed 1 year ago
Thanks for reporting, @Bharati17 !
I don't see junixsocket in the stack trace, it could be a bug in MySQL Connector. It could also be both (a bug in C/J that's triggered by a bug in junixsocket).
Most likely it has to do with something that's loaded via reflection and not properly configured for Native-Image. We can sort this out.
Does the socket connection work when you use TCP (i.e., not via junixsocket)?
Hi kohlschuetter , Thank you for looking into it. The TCP Connection worked. However, socket connection failed. Like you mentioned, it was the metadata which was missing. Once I copied all the metadata(mentioned in https://kohlschutter.github.io/junixsocket/graalvm.html) jsons from junixcommon to GraalVM config, it worked like a charm. That was the missing piece. Closing this ticket.
I am trying to connect my local MySQL database, from a GraalVM native image using junixsocket
To Reproduce Steps to reproduce the behavior:
Expected behavior MySQL database connection should be successful
Output/Screenshots java.sql.SQLNonTransientConnectionException: Cannot connect to MySQL server on localhost:3,306.
Make sure that there is a MySQL server running on the machine/port you are trying to connect to and that the machine this software is running on is able to connect to this host/port (i.e. not firewalled). Also make sure that the server has not been started with the --skip-networking flag.
Caused by: java.lang.ClassCastException: com.mysql.cj.exceptions.CJException cannot be cast to com.mysql.cj.exceptions.UnableToConnectException at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:825) at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:448)
... 5 more
Environment (please complete the following information):
Notes A normal jdbc connection without socket works. Am using 2.6.0 version of junixsocket and 22.3 version of GraalVM