ClassNotFoundException: com.mysql.jdbc.GoogleDriver

后端 未结 1 930
温柔的废话
温柔的废话 2020-12-19 20:37

I wonder how come this error is thrown while hosting my project in APP ENGINE, I have added lots of logging just for analysis sake. When I use the com.mysql.jdbc.Driver usin

1条回答
  •  佛祖请我去吃肉
    2020-12-19 21:22

    As shwown in this tutorial, during development you should use the normal mysql driver and only appengine use the Google mysql driver

      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";
      }
    

    Also double check that you have enabled MySQL Connector/J for your application (it's not done by default)

    https://developers.google.com/appengine/docs/java/cloud-sql/#enable_connector_j

    
    
      ...
      true
    
    

    0 讨论(0)
提交回复
热议问题