Hi I am using below configuration still I am getting error.
spring.datasource.url=jdbc:oracle:thin#sca00tof.us.dell.com:1521:mfg1229
spring.datasource.username=apps
spring.datasource.password=xxxx
spring.datasource.driver-class=oracle.jdbc.driver.OracleDriver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=Oracle12cDialect
below dependency i used in pom.xml
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<scope>runtime</scope>
</dependency>
still I am getting below error.
Caused by: java.lang.ClassNotFoundException: Could not load requested class : Oracle12cDialect
at org.hibernate.boot.registry.classloading.internal.AggregatedClassLoader.findClass(AggregatedClassLoader.java:210) ~[hibernate-core-5.4.23.Final.jar:5.4.23.Final]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
at java.base/java.lang.Class.forName0(Native Method) ~[na:na]
at java.base/java.lang.Clas?s.forName(Class.java:427) ~[na:na]
enter code here
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:130) ~[hibernate-core-5.4.23.Final.jar:5.4.23.Final]
... 28 common frames omitted
WHat is the problem in my configuration. instead of driver-class i also checked with driver-class-name
I checked OracleDialect, Oracle10gDialect and Oracle12cDialect . for all the 3 i am getting same error.
there is nothing like "Oracle12cDialect" dialect. you need to write in proper way. :--
in your property file it is:
spring.jpa.properties.hibernate.dialect=Oracle12cDialect
spring.datasource.driver-class=oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin#sca00tof.us.dell.com:1521:mfg1229
but it should be:--
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.Oracle12cDialect
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin#//sca00tof.us.dell.com:1521/mfg1229
if does not work then please change to:
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
The dialect for Oracle12c can be use with hibernate 5.x.
You should add this to your classpath:
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.24.Final</version>
</dependency>
Please note that you need the dialect for the coreesponding Version of Oracle DB.
How ever I can't see the exact framework you are using. Please check that the obove dependency is part of your classpath. This may come with other dependencies such as JPA oder spring-data.
Also please note that your jdbc string seems to be wrong.
It should look like this:
url="jdbc:oracle:thin:#sca00tof.us.dell.com:1521:mfg1229"
See here for details: URL string format for connecting to Oracle database with JDBC
So I have a java program and am using the following driver
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
to try to read data from a SQL server 2012 database, but I get the
java.sql.SQLException: No suitable driver found for jdbc:sqlserver://localhost....
If I have a SQL server 2012 database, can I not use the com.microsoft.sqlserver.jdbc.SQLServerDriver driver? Any help will be greatly appreciated.
You might be missing the driver class and you should add that to your project.
Just a quick search on the Maven Central produces this:
<!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.4.0.jre8</version>
<scope>test</scope>
</dependency>
Assuming that you run Java 8 and Maven, you can add this as a dependency to your project.
I have a app running with JDBC and get data from MySQL, but I can't build it because of this error :
java.sql.SQLException: Unknown system variable 'query_cache_size'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964) ~[mysql-connector-java-5.1.41.jar:5.1.41]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973) ~[mysql-connector-java-5.1.41.jar:5.1.41]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909) ~[mysql-connector-java-5.1.41.jar:5.1.41]
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527) ~[mysql-connector-java-5.1.41.jar:5.1.41]
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680) ~[mysql-connector-java-5.1.41.jar:5.1.41]
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2497) ~[mysql-connector-java-5.1.41.jar:5.1.41]
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2455) ~[mysql-connector-java-5.1.41.jar:5.1.41]
at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1369) ~[mysql-connector-java-5.1.41.jar:5.1.41]
at com.mysql.jdbc.ConnectionImpl.loadServerVariables(ConnectionImpl.java:3777) ~[mysql-connector-java-5.1.41.jar:5.1.41]
at com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3240) ~[mysql-connector-java-5.1.41.jar:5.1.41]
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2249) ~[mysql-connector-java-5.1.41.jar:5.1.41]
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2035) ~[mysql-connector-java-5.1.41.jar:5.1.41]
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:790) ~[mysql-connector-java-5.1.41.jar:5.1.41]
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) ~[mysql-connector-java-5.1.41.jar:5.1.41]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_131]
I have file application.properties here
#specs.dir=/specs/
#
#################### Spring Boot Data Source Configuration ############
#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#spring.datasource.url=jdbc:mysql://localhost:3306/savingbooking?useSSL=false
#spring.datasource.username=root
#spring.datasource.password=ZAQ!2wsx
#spring.datasource.initialize=true
#spring.jpa.hibernate.ddl-auto=update
#spring.jpa.properties.hibernate.format_sql=true
#spring.jpa.show-sql=true
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
Mysql workbench is 8.0 version
query_cache_size was removed in MySQL 8. Check the docs.
It works with JDBC driver 5.1.44.
java.sql.SQLException: Unknown system variable 'query_cache_size'
In pom file of your project, just update the version of the dependency.
For example it's 6.0.2 of mysql java connector just update it to latest one like 8.0.11
It works!!!!
I had a similar problem.
I resolved it by specifying the version in mysql dependency
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.45</version>
<scope>runtime</scope>
</dependency>
Worked like a charm for me.
Try using MySQL 8.0.3
As can be seen on the docs, the query_cache_size was removed on MySQL8. JetBrains guys have suffered the same issue, is seems to be that it is fixed by updating the driver to the version MySQL JDBC driver v 5.1.44.
For mysql 8:
mysql-connector-java-8.0.17.jar (or above)
+
db.driver=com.mysql.cj.jdbc.Driver instead of com.mysql.jdbc.Driver
I stuck on this issue, spend full one day and finally i got solution.
Solution :
1) Use exact mysql-connector-java jar or dependency as your mysql version.
2) if your mysql version is 8 or 6+ try to use this "com.mysql.cj.jdbc.Driver" driver class.
If you using MySql v8.0 then you should try fix this bug with
mysql-connector-java-5.1.9
This exception is related to pom.xml dependency.
When I use below dependency in pox.xml:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.5</version>
</dependency>
It shows exception:Caused by: java.sql.SQLException: Unknown system variable query_cache_size
But, when I use below dependency:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.13</version>
</dependency>
It works.You have to use latest dependency
Ok so what I did as metioned above. I just added the mysql-connector-java-5.1.4 to build path and ran the project on my server and connected fine to mysql
just change the version of mysql
use this in pom.xml
<version>8.0.11</version>
Use Below mention dependency it will work for you!
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.16</version>
</dependency>
This question already has answers here:
Connect Java to a MySQL database
(14 answers)
Closed 5 years ago.
i am working on jax-rs(jersey) and want to connect to database by using hibernate. my projects works perfectly fine when i debug it as java application but as i run my project on server it gives No suitable driver found for jdbc:mysql://localhost:3306/sample
here is my hibernate.cfg.xml file
the sql exception is here
Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/sample
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:208)
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:301)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:214)
You have to download the MySQL Connector/J and add it to your class path
If you are using maven you can use this dependency :
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.18</version>
</dependency>
I am trying to run the liquibase update from Openshift machine that I have. It looks like
> java -jar ~/.m2/repository/org/liquibase/liquibase-core/3.1.1/liquibase-core-3.1.1.jar --driver=org.postgresql.Driver --classpath=wildfly/standalone/deployments/ROOT.war --changeLogFile=liquibase/changelog.xml --url="jdbc:$OPENSHIFT_POSTGRESQL_DB_URL/mydb" --username=$OPENSHIFT_POSTGRESQL_DB_USERNAME --password=OPENSHIFT_POSTGRESQL_DB_PASSWORD update
and I see the following error
Liquibase update Failed: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to jdbc:postgresql://admin:29asDVjpFxYl6#127.8.201.2:5432/mydb with driver org.postgresql.Driver. Possibly the wrong driver for the given database URL
What is going wrong here?
I am using the following postgreSQL dependency
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
there were 2 issues that were fixed as following
a.) using postgres 9.2 driver
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.2-1003-jdbc4</version>
</dependency>
b.) using the following url
--url="jdbc:postgresql://$OPENSHIFT_POSTGRESQL_DB_HOST:$OPENSHIFT_POSTGRESQL_DB_PORT/mydb"