连接到Google App Engine SQL实例错误

时间:2015-10-15 20:48:02

标签: java mysql eclipse google-app-engine

我正在尝试从eclipse连接到Google SQL实例。我在我的web-inf lib文件夹中添加了SQL驱动程序jar: mysql-connector-java-5.0.8-bin.jar

// Connecting from App Engine.
if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) {     
    // Load the class that provides the "jdbc:google:mysql://" prefix.
    Class.forName("com.mysql.jdbc.GoogleDriver");
    url ="jdbc:google:mysql://appid:instance/dbname";
} else {
    // Connecting from an external network.
    Class.forName("com.mysql.jdbc.Driver");
    url = "jdbc:mysql://173.*.*.*:3306?user=root";
}      

Connection conn = DriverManager.getConnection(url,"***","***");
Log.info(url);
ResultSet rs = conn.createStatement().executeQuery(
"SELECT * from icidev.users");
log.info(rs.toString())

这是输出:

Oct 15, 2015 4:13:25 PM **com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException
SEVERE: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container
java.lang.ExceptionInInitializerError**
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at com.intellioption.callinfo.MyService.connectDB(MyService.java:61)
    at com.intellioption.callinfo.MyService.getEmployee(MyService.java:30)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:130)

**Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")**
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:429)
    at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkAccess(DevAppServerFactory.java:454)
    at java.lang.ThreadGroup.checkAccess(Unknown Source)

我可以使用本地MySQL进行连接,只需验证我的凭据。

0 个答案:

没有答案