java.lang.IllegalStateException: Could not load JDBC driver class [com.mysql.jdbc.GoogleDriver]

已查看 1,761 次
跳至第一个未读帖子

Dhyanandra Singh

未读,
2016年10月24日 09:46:542016/10/24
收件人 Google App Engine

 i am developing an project based on spring and hibernate and want to deploy it on GCE.

so i  added  mysql connector

<dependency>                     <!-- http://dev.mysql.com/doc/connector-j/en/ -->
           
<groupId>mysql</groupId>
           
<artifactId>mysql-connector-java</artifactId>
           
<version>6.0.5</version>
 
</dependency>

then i added appengine-web.xml and enable
use-google-connector-j


<?xml version="1.0" encoding="utf-8"?>

<!-- [START config] -->
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
 
<application>yugma-146007</application>
   
<vm>true</vm>
 
<threadsafe>true</threadsafe>
 
<use-google-connector-j>true</use-google-connector-j>
 
<system-properties>
   
<property name="ae-cloudsql.cloudsql-database-url" value="jdbc:google:mysql://Instance:us-central1:DBInstance/dbName?user=root&amp;password=xxxxxxx;" />
   
</system-properties>
</appengine-web-app>
<!-- [END config] -->

i have an application.property file
jdbc.driverClassName = com.mysql.jdbc.GoogleDriver
jdbc
.url = jdbc:google:mysql://prjectInstance:us-central1:dbInstance/dbName
jdbc
.username = root
jdbc
.password = xxxxxxxx
hibernate
.dialect = org.hibernate.dialect.MySQL5Dialect    
hibernate
.hbm2ddl.auto= update
hibernate
.show_sql = true
hibernate
.format_sql = true

but when i upload it, it will throw an error
 Caused by:
 java
.lang.IllegalStateException: Could not load JDBC driver class [com.mysql.jdbc.GoogleDriver]
   at org
.springframework.jdbc.datasource.DriverManagerDataSource.setDriverClassName(DriverManagerDataSource.java:130)
   at com
.appointment.schedular.configuration.HibernateConfiguration.dataSource(HibernateConfiguration.java:41)
   at com
.appointment.schedular.configuration.HibernateConfiguration$$EnhancerBySpringCGLIB$$8e307f3.CGLIB$dataSource$1(<gene

   at com
.appointment.schedular.configuration.HibernateConfiguration$$EnhancerBySpringCGLIB$$8e307f3$$FastClassBySpringCGLIB$


how can i solve this problem.
已删除帖子

Dhyanandra Singh

未读,
2016年10月25日 04:19:392016/10/25
收件人 Google App Engine



 i also tried

<dependency>
 
<groupId>com.google.cloud.sql</groupId>
 
<artifactId>mysql-socket-factory</artifactId>
 
<version>1.0.1</version>
</dependency>

and configured app.yaml


runtime
: java
vm
:      true

handlers
:
- url: /.*
  script: this field is required, but ignored
  secure: always  # Require HTTPS

# [START env_variables]
env_variables:    # Logging options
  JAVA_OPTS: >-
    -D.level=INFO
  SQL_URL: jdbc:mysql:/
/google/db?cloudSqlInstance=projectInstanceId:us-central1:dbInstance&socketFactory=com.google.cloud.sql.mysql.SocketFactory&user=root&password=xxxxxxx
# [END env_variables]
# [END runtime]

runtime_config
:   # Optional
  jdk
: openjdk8
  server
: jetty9
 
beta_settings
:
      cloud_sql_instances
: "projectInstanceId:us-central1:dbInstance"

application.properties
jdbc.driverClassName = com.mysql.jdbc.Driver
jdbc
.url = jdbc:mysql://google/db?cloudSqlInstance=projectInstance:us-central1:dbInstance&socketFactory=com.google.cloud.sql.mysql.SocketFactory

jdbc
.username = root
jdbc
.password = xxxxxxxx
hibernate
.dialect = org.hibernate.dialect.MySQL5Dialect

hibernate
.hbm2ddl.auto = update
hibernate
.show_sql = true
hibernate
.format_sql = true




 
it again not connecting with db and through
Caused by:
java
.lang.NoClassDefFoundError: com/mysql/jdbc/SocketFactory
  at java
.lang.ClassLoader.defineClass1(Native Method)
  at java
.lang.ClassLoader.defineClass(ClassLoader.java:763)



     

 



Dhyanandra Singh

未读,
2016年10月25日 04:52:262016/10/25
收件人 Google App Engine
problem is solved when i degrade `mysql-connector-java` from 6.0.4 to 5.1.31

FUJIWARA HAO

未读,
2018年6月18日 11:07:172018/6/18
收件人 Google App Engine
hi, what is ur complete application.properties?
I am here facing the same issue as yours.
回复全部
回复作者
转发
0 个新帖子