0
我已經搜索了很多主題,但沒有人能幫助我。這裏是我的情況:無法連接到谷歌可以SQL數據庫(找不到合適的驅動程序....)
- 應用程序在App Engine(柔性)
- 第二代MySQL數據庫
- 無論是在同一個項目
依賴在pom.xml存在:
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>1.9.48</version>
</dependency>
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
Java代碼:
String jdbcUrl = String.format(
"jdbc:mysql://google/%s?cloudSqlInstance=%s&socketFactory=com.google.cloud.sql.mysql.SocketFactory",
"MyTable",
"xxxx:us-central1:xxxx");
con = DriverManager.getConnection(jdbcUrl, "root", "xxxxxx");
Statement statement = con.createStatement();
ResultSet resultSet = statement.executeQuery("SHOW TABLES");
while (resultSet.next()) {
...
}
我收到以下錯誤,當我已經部署使用的應用程序到雲:
mvn appengine:update
No suitable driver found for jdbc:mysql://google/MyTable?cloudSqlInstance=xxxx:us-central1:xxxx&socketFactory=com.google.cloud.sql.mysql.SocketFactory
據我瞭解,我不需要使用,谷歌連接器-J在我appengine- web.xml
任何人有任何線索?我一直在爲此奮鬥了近兩天...
謝謝。