java JDBC Driver connection [duplicate] - java

This question already has answers here:
Error: Client does not support authentication protocol requested by server; consider upgrading MySQL client
(4 answers)
Closed 3 years ago.
Whenever i am executing my code of creating connection:
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/sonoo");
I am getting this exception,
com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Client
does not support authentication protocol requested by server; consider
upgrading MySQL client
What is the solution of this problem?

Download the newest version of JDBC. I had the same problem. I downloaded another version and it worked!!

Related

Error "The Network Adapter could not establish the connection" while connecting to Oracle [duplicate]

This question already has answers here:
IO Error: The Network Adapter could not establish the connection
(12 answers)
Io exception: The Network Adapter could not establish the connection
(5 answers)
Closed 5 months ago.
I have Installed Oracle 21c express edition DB. I tried to connect it to my Java application but I am getting "Io exception: The Network Adapter could not establish the connection"
ojdbc14.jar file is already loaded.
Oracle DB directory is
C:\app\Usersxyz\product\21c\

Communication link Failure : access java web app [duplicate]

This question already has answers here:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
(51 answers)
Closed 3 years ago.
I was trying to access my java web app , which i have containerised with docker containers and i also have containerised my mysql database in a different container , both container are running on the default docker network , and i also tried to ping those containers from each other and i got positive results from it , but when i try to access it on my localhost (as i have mapped the ports of the tomcat server to the host ) machine it shows
Error
Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
I have read a little bit about this error , its related to some sort of connectivity issue with database but through pingcommand , i checked the connection.
What could be the reason of this error?
1) If it is bound to 127.0.0.1 and you can't connect using "localhost", make sure it's not resolving to the IPv6 localhost address instead of IPv4. (or just use the IP address)
2) Check the port that MySQL is listening on (Default 3306).
3) Make sure you're using the right JDBC connector for your JDK.
Check this below code in your application.yml or application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/<<DB_NAME>>
spring.datasource.username=root (In my case)

connecting to remote mysql server using intelij [duplicate]

This question already has answers here:
Solving a "communications link failure" with JDBC and MySQL [duplicate]
(25 answers)
Closed 4 years ago.
I have mysql database running on server that i access using <ip>/phpmyadmin.
I want to create data source in intelij and i am trying to connect there.
Host: <ip>/phpmyadmin
Database: <database_name>
User:root
password: *****
Url: jdbc:mysql://<ip>/phpmyadmin:3306/<database_name>
However using this i recieve error from intelij:
> Connection to jdbc:mysql://<ip>/phpmyadmin:3306/<database_name>
> failed. [08S01] Communications link failure. The last packet sent
> successfully to the server was 0 milliseconds ago. The driver has not
> received any packets from the server.
Why is this happening? Going to <ip>/phpmyadmin in broswer nicely delegates me to phpmyadmin, so why is intelij complaining? The url should be correct, the mysql database is running on port 3306 on server.
How can i fix this?
thanks for help!
Remove phpadmin path from your host and try to connect again. If it doesn't work, check on which port MySQL is running by
mysql> SHOW GLOBAL VARIABLES LIKE 'PORT';

The Java application can not access the database on the Google Cloud platform [duplicate]

This question already has answers here:
Connecting to Google cloud sql from Java stand alone application
(3 answers)
Google Cloud SQL with SSL from Compute Engine and/or External Network
(1 answer)
App Engine Java Servlet does not connect to Cloud SQL
(5 answers)
Closed 5 years ago.
At this moment try deploy a simple Java aplication on the Google cloud platform.But only the start page (login) and the registration page are open for now. When I try to register a new user I get an error:
org.springframework.orm.jpa.JpaSystemException: Could not open connection; nested exception is org.hibernate.exception.GenericJDBCException: Could not open connection
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException (HibernateJpaDialect.java:244)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible (HibernateJpaDialect.java:155)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible (AbstractEntityManagerFactoryBean.java:417)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible (ChainedPersistenceExceptionTranslator.java:59)
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary (DataAccessUtils.java:213)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke (PersistenceExceptionTranslationInterceptor.java:147)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:179)
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodIntercceptor.invoke (CrudMethodMetadataPostProcessor.java:122)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke (ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke (JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy42.findByUsername (Unknown Source)
at project.security.service.UserServiceImpl.findByUsername (UserServiceImpl.java:38)
at project.security.validator.UserValidator.validate (UserValidator.java:32)
at project.security.controller.UserController.registration (UserController.java:38)
I know that the problem with accessing the database is `Cloud MySQL. ' And I can not understand what I'm doing wrong.When I run the application on the local server everything is working fine.I tried various options for running the application, but the error is always the same.
Link to the code https://github.com/Ditrim023/MVC_for_money.
A link to the not working application change-curr.appspot.com .
I will be happy with any help.
Following the java docs for Google Cloud, you have an invalid connection string in your properties file.
You have defined:
jdbc:google:mysql://exchange-6/secur?user=root
From the docs, try using
String jdbcUrl = String.format(
"jdbc:mysql://google/%s?cloudSqlInstance=%s&"
+ "socketFactory=com.google.cloud.sql.mysql.SocketFactory",
databaseName,
instanceConnectionName);
Make sure in google cloud that you added your ip address to database permissions. Or add 0.0.0.0/0 to allow any IP address to connect to your database. However this is not recommended.

Can't connect to MySQL Database from Java [duplicate]

This question already has answers here:
Connect Java to a MySQL database
(14 answers)
Closed 7 years ago.
I recently set up an OpenShift project with the MySQL 5.5 cartridge.
Now I'm trying to reach this server. The DB name is 'wensput'.
The URL I'm trying to reach the MySQL is:
DB_URL = "jdbc:mysql://77.78.110.71:3306/Wensput";
AND
DB_URL = "jdbc:mysql://IP/wensput";
WHERE IP = the IP my machine uses to connect to phpAdmin, also the 'Server' (something like: 127.9.203.293:3306
I tried them both with capatilazing and such but nothing seems to work.
Now was my question, do I have the url right?
Or do I need to use like, the rhcloud.com/phpmyadmin url? What am I doing wrong?
EDIT: ****
I first get a java.lang.ClassNotFoundException: com.mysql.jdbc.Driver exception, but: there are no complains about 'CLASSPATH' whatsoever.
Looks like you don't have the JDBC driver installed or are not importing it correctly. Take a look at this tutorial for detailed instructions:
Connect Java to a MySQL database

Categories