0
我正嘗試使用android studio連接到雲端SQL。收到此錯誤連接到雲時收到套接字錯誤SQL
07-30 16:51:12.511 23120-23120/com.example.pratyush.geofencing W/System.err: java.sql.SQLException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/cloud/sql/mysql/SslSocketFactory;
我的代碼:
public void getDatafromSQL() {
Log.d("GeoL", "getSQL");
Connection connection;
String query = "Some query";
try {
String databaseName = "dbName";
String instanceConnectionName = "instnce name";
String jdbcUrl = String.format(
"jdbc:mysql://google/%s?cloudSqlInstance=%s&"
+ "socketFactory=com.google.cloud.sql.mysql.SocketFactory",
databaseName,
instanceConnectionName);
connection = DriverManager.getConnection(jdbcUrl, "user", "pwd");
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query);
Log.d("GeoL", String.valueOf(resultSet));
} catch (SQLException e) {
e.printStackTrace();
}
}
我使用的MySQL連接器JAR和mysql套接字工廠的水瓶中相依。
另外我無法使用compile'com.google.cloud.sql:mysql-socket-factory:1.0.3'作爲依賴項。
請幫忙。
在此先感謝。