您好我无法通过eclipse(Neon)连接到我的google云端sql实例 我尝试了app engine sdk插件1.9.34和1.9.42(google插件4.6)
Could not connect to Profile (projectID.GoogleCloudSQL.DevInstance).
Error creating SQL Model Connection connection to Profile(projectID.GoogleCloudSQL.DevInstance). (Error: com.mysql.jdbc.Driver)
com.mysql.jdbc.Driver
Error creating Google Cloud SQL Connection factory connection to Profile (ProjectId.GoogleCloudSQL.DevInstance). (Error: com.mysql.jdbc.Driver)
com.mysql.jdbc.Driver
Ping失败!
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:814)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.createConnection(JDBCConnection.java:327)
at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(DriverConnectionBase.java:105)
at org.eclipse.datatools.connectivity.DriverConnectionBase.open(DriverConnectionBase.java:54)
at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.open(JDBCConnection.java:96)
at com.google.appengine.eclipse.datatools.connection.GoogleSqlConnectionFactory.createConnection(GoogleSqlConnectionFactory.java:36)
at org.eclipse.datatools.connectivity.internal.ConnectionFactoryProvider.createConnection(ConnectionFactoryProvider.java:83)
at org.eclipse.datatools.connectivity.internal.ConnectionProfile.createConnection(ConnectionProfile.java:359)
at org.eclipse.datatools.connectivity.ui.PingJob.createTestConnection(PingJob.java:76)
at org.eclipse.datatools.connectivity.ui.PingJob.run(PingJob.java:59)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
答案 0 :(得分:0)
由于这个问题从来没有得到答案,我会在这里张贴一个。
直接在代码中实例化意味着执行此操作:
Class.forName("com.mysql.jdbc.Driver");
这将尝试手动加载类并运行其静态初始化程序。消息"java.lang.ClassNotFoundException: com.mysql.jdbc.Driver"
表示该类不在您的类路径中,因此如果您收到相同的错误,则表示您丢失了JAR,或者它不在其应有的位置。
由于您提到使用Google Plugin for Eclipse,我将假设您正在使用App Engine项目。对于这种类型的项目,您的JAR必须位于WEB-INF/lib
目录中,因此请确保mysql-connector-java
JAR在那里。