GAE和本地MysqlServer问题:访问被拒绝(“java.lang.RuntimePermission”modifyThreadGroup)
我已经尝试了一个解决方案,我已经做了几个步骤来解决这个问题,但没有成功。我最后的希望是这个话题 我有一个本地的Mysql服务器正在运行,我正在Android Studio中使用谷歌应用程序引擎。我的后端无法与本地数据库通信。我在Google中创建了一个SQL数据库,在GAE上部署SQL时,使用Google数据库可以很好地工作。该问题仅在本地环境中发生 我的代码:GAE和本地MysqlServer问题:访问被拒绝(“java.lang.RuntimePermission”modifyThreadGroup),java,android,mysql,google-app-engine,Java,Android,Mysql,Google App Engine,我已经尝试了一个解决方案,我已经做了几个步骤来解决这个问题,但没有成功。我最后的希望是这个话题 我有一个本地的Mysql服务器正在运行,我正在Android Studio中使用谷歌应用程序引擎。我的后端无法与本地数据库通信。我在Google中创建了一个SQL数据库,在GAE上部署SQL时,使用Google数据库可以很好地工作。该问题仅在本地环境中发生 我的代码: public Connection getConnection() throws SQLException { St
public Connection getConnection() throws SQLException {
String url = null;
try {
if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) {
// Load the class that provides the new "jdbc:google:mysql://" prefix.
Class.forName("com.mysql.jdbc.GoogleDriver");
url = "jdbc:google:mysql://XXXXXt:us-central1:YYYYYY/Project?user=root&password=xxxxx";
} else {
// Local MySQL instance to use during development.
Class.forName("com.mysql.jdbc.Driver");
url = "jdbc:mysql://127.0.0.1:3306/Project?user=root&password=xxxxx";
// Alternatively, connect to a Google Cloud SQL instance using:
// jdbc:mysql://ip-address-of-google-cloud-sql-instance:3306/guestbook?user=root
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return DriverManager.getConnection(url);
}
Gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.34'
}
}
repositories {
mavenCentral()
jcenter();
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.49'
compile 'com.google.appengine:appengine-endpoints:1.9.34'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.34'
compile 'javax.servlet:servlet-api:2.5'
compile 'com.google.apis:google-api-services-sqladmin:v1beta4-rev37-1.22.0'
compile 'com.google.cloud.sql:mysql-socket-factory:1.0.2'
compile 'mysql:mysql-connector-java:5.1.40'
}
appengine {
downloadSdk = true
httpAddress = "0.0.0.0"
appcfg {
oauth2 = true
}
endpoints {
getClientLibsOnBuild = true
getDiscoveryDocsOnBuild = true
}
}
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>myApplicationId</application>
<version>1</version>
<threadsafe>true</threadsafe>
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties" />
</system-properties>
<use-google-connector-j>true</use-google-connector-j>
</appengine-web-app>
应用程序引擎:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.34'
}
}
repositories {
mavenCentral()
jcenter();
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.49'
compile 'com.google.appengine:appengine-endpoints:1.9.34'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.34'
compile 'javax.servlet:servlet-api:2.5'
compile 'com.google.apis:google-api-services-sqladmin:v1beta4-rev37-1.22.0'
compile 'com.google.cloud.sql:mysql-socket-factory:1.0.2'
compile 'mysql:mysql-connector-java:5.1.40'
}
appengine {
downloadSdk = true
httpAddress = "0.0.0.0"
appcfg {
oauth2 = true
}
endpoints {
getClientLibsOnBuild = true
getDiscoveryDocsOnBuild = true
}
}
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>myApplicationId</application>
<version>1</version>
<threadsafe>true</threadsafe>
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties" />
</system-properties>
<use-google-connector-j>true</use-google-connector-j>
</appengine-web-app>
myApplicationId
1.
真的
真的
有什么建议吗