简体   繁体   中英

Google App Engine Guestbook Sample not working, can't connect to DB

i can't get the Google App Engine "Guestbook" sample to work with my local mySQL DB. https://developers.google.com/appengine/docs/java/cloud-sql/

I get following Exceptions:

java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")

and

Nested in javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class com.mysql.jdbc.ConnectionImpl:

This is the code i try to connect with (actually only the last 2 rows are relevant):

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://your-project-id:your-instance-name/guestbook?user=root";
} else {
  // Local MySQL instance to use during development.
  Class.forName("com.mysql.jdbc.Driver");
  url = "jdbc:mysql://127.0.0.1:3306/guestbook?user=root";
}

I also can't connect to to my google cloud sql instance. The only way it works is when i deploy it to GAE..

I'm already searching for a solution for hours.. Actually i already managed it to work for some time(don't know how i did it), then i refactored the project and did some other minor changes in eclipse and now i again get the exception..

The problem is likely due to the local application not able to locate your MySQL JDBC Driver JAR file. See if a similar thread here solves your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM