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
Related
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!!
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';
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.
This question already has answers here:
Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server
(29 answers)
Closed 9 years ago.
Using JDBC, I am currently trying to connect to a server hosted on the same network using MAMP.
Using this string: private static final String DB_CONNECTION = "jdbc:mysql://192.168.169.101:8889/";
I received this error: message from server: "Host '192.168.169.98' is not allowed to connect to this MySQL server"
I am wondering if this is a firewall error?
Comment out 'skip-networking' in your my.cnf file.
If skip-networking is commented out, then it's a user level permission which needs to be set in the mysql.user or mysql.database tables.
MySQL wants you to GRANT permission for users to connect to the server by IP address and credentials. I think it's a good idea to set up credentials for that particular database and user and GRANT only the permissions necessary to accomplish the task.
Don't use the root admin credentials for anything except administration.
http://dev.mysql.com/doc/refman/5.1/en/adding-users.html
This question already has answers here:
The infamous java.sql.SQLException: No suitable driver found
(21 answers)
Closed 7 years ago.
Hi i have found a seemingly common problem, i cant interact with a mysql db. This no suitable driver found keeps happening.
I have followed most threads on this same question, however i was not able to replicate their solution so am posting my own specific question.
(Mostly this thread: I can't load the JDBC driver for MySQL)
My code:
public DBManager(){
try {
//Class.forName("com.mysql.jdbc.Driver");
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
con=DriverManager.getConnection("jdbc:mysql:3306//localhost/test","root","root");
//con=DriverManager.getConnection(c);
if(!con.isClosed()) {
con.close();
}
}
catch (SQLException e) {
e.printStackTrace();
}
Now, i read that on newer drivers you dont need either Class.forName () or registerDriver();
i have tried both and i still cant get it to work.
The thing is am developing on a windows machine, with eclipse Indigo and Connector/J 5.1.17
and deploying (and debugging) on a remote linux with the same Connector.
Am launching my debug sessions with
java -Xdebug -Xrunjdwp:transport=dt_socket,address=8998,server=y -classpath /home/dev/mysql-connector-java-5.1.17-bin.jar -jar devserver.jar
and i get that exception. Any help?
I come from a heavy c# development environment, so if i have to meddle with classpaths and such please try to step it by step as im not very familiar with that.
SQLException: no suitable driver
You will get this exception whenever the DriverManager#getConnection() cannot find a suitable driver for the given connection URL. This in turn happens when the Driver#acceptsURL() has returned false for any of the loaded drivers.
And indeed, your connection URL is wrong:
jdbc:mysql:3306//localhost/test
It should have been:
jdbc:mysql://localhost:3306/test
See also the MySQL JDBC manual.
The JDBC URL format for MySQL Connector/J is as follows, with items in square brackets ([, ]) being optional:
jdbc:mysql://[host][,failoverhost...][:port]/[database] »
[?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]...
If the host name is not specified, it defaults to 127.0.0.1. If the port is not specified, it defaults to 3306, the default port number for MySQL servers.
jdbc:mysql://[host:port],[host:port].../[database] »
[?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]...
If the database is not specified, the connection will be made with no default database.