I want to write a java stand alone application to connect to Google cloud sql - Mysql database. I could find samples for app client but not for stand alone java application.
When I tried to do this, I get the following error.
Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:google:mysql://IP:Instance_name?user=user_name"); Statement st = con.createStatement(); ResultSet rs = con.createStatement().executeQuery("SELECT 1 + 1");
It fails with error :
No suitable driver found for jdbc:google:mysql:..
I see some answers where they have asked to enabled mysql connector. But it is the case with app engine project. How do I do it with stand alone application?
Edit inside <> before running your code
You can just use the standard mysql connector to connect to cloud sql instance: e.g:
DriverManager.getConnection("jdbc:mysql://IP:Instance_name?user=user_name");
You can check https://cloud.google.com/sql/docs/external for more information