I am new play framework. I am trying to connect to mysql database on linux server. it is not working !!
I am getting an error:
A database error occured : Cannot connected to the database, 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.
anyway I am able to connect linux server through my MySQL Work bench.
application.mode=dev
%prod.application.mode=prod
jpa.ddl=update
db.url=jdbc:mysql://<ipaddress>:3306/<database>?useUnicode=false&characterEncoding=ISO-8859-1&connectionCollation=utf8_swedish_ci
db.driver=com.mysql.jdbc.Driver
db.user=<user>
db.pass=<password>
ensure that you have the correct ip address and port nunmber for mysql in the config file (as well as the correct username/pwd).
you can check if mysql is listening on the port (try netstat -an | grep 3306).
Related
I installed zabbix 4.0 in centOs 7 and configured it to connect to remote mysql.
But log file says that it can not connect to DB.
I tried to telnet to DB machine and I was OK!
telnet 10.1.13.33 3306
Trying 10.1.13.33...
Connected to 10.1.13.33.
here is my /etc/zabbix/zabbix_server.conf:
SourceIP=10.1.9.140
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
DebugLevel=5
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=10.1.13.33
DBName=zabbix
DBUser=zabbix
DBPassword=******************
DBPort=3306
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
When starting zabbix, in /var/log/zabbix/zabbix_server.log there is a line like this:
[Z3001] connection to database 'zabbix' failed: [2003] Can't connect to MySQL server on '10.1.13.33' (13)
database is down: reconnecting in 10 seconds
By default, Zabbix server does not understand which IP to be listened. So you have to also mention your ListenIP in /etc/zabbix/zabbix_server.conf:
ListenIP=<your_ip>
This question already has answers here:
Connect Java to a MySQL database
(14 answers)
Closed 5 years ago.
I am fairly new to liquibase and try to set it up on my own computer, running Windows 7 with a local MySQL Server. I have installed the JDBC driver (4.2), opened the TCP/IP Port 3306 on my Firewall and the Server, installed liquibase and added it as a PATH in the environment variables.
As a first command i tried using this:
C:\Users\Marius>H:\Liquibase\Liquibase \
--driver=com.microsoft.sqlserver.jdbc.SQLServerDriver \
--classpath="C:\\Program Files\\Microsoft JDBC Driver 6.2 for SQL Server\\sqljdbc_6.2\\enu\\mssql-jdbc-6.2.2.jre7.jar" \
--url="jdbc:sqlserver://localhost:3306; databaseName=Test" \
--changeLogFile="H:\Liquibase\dbchangelog.xml" \
--username=liquibase \
--password=liquibase \
Update
But when executing I only get:
Unexpected error running Liquibase:
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection
to the host localhost, port 3306 has failed. Error: "Connection
refused: connect. Verify the connection properties. Make sure that an
instance of SQL Server is running on the host and accepting TCP/IP
connections at the port. Make sure that TCP connections to the port
are not blocked by a firewall.".
The Server is definitely running since I am able to connect to it with telnet, mySQLWorkbench and several other tools.
When running the command with --url="jdbc:sqlserver:localhost:3306; databaseName=Test", I get a different error code.
Unexpected error running Liquibase:
liquibase.exception.DatabaseException: Connection could not be created
to jdbc:sqlserver:localhost:3306; databaseName=Test with driver
com.microsoft.sqlserver.jdbc.SQLServerDriver. Possibly the wrong
driver for the given database URL
I tried this again on another computer with a SQL Server 2017, a different JDBC driver (6.0 and 6.2) and Windows 10 as the OS.
Deactivating the Firewall doesn't do anything, neither does a clean install of everything.
Any help is appreciated.
MySQL is a different product to Microsoft SQL Server. Given you have said you can connect using MySQL workbench, this is probably the product you have installed.
Instead of trying to connect to the non-existent Microsoft SQL Server, try using a MySQL driver instead.
I'm trying to connect my glassfish with a mysql server (installed via XAMPP) and it says:
Ping Connection Pool failed for jdbc/xxxx. Connection could not be allocated because: 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. Please check the server.log for more details.
My configs in glassfish are:
URL: jdbc:mysql://localhost:3306/SIRS
User: root
Password: xxxxxxx
Both servers are in the same pc running ubuntu.
I have the same configurations working properly in another pc but without XAMPP installation, I've installed mysql server with apt-get install mysql... command.
Any ideas why is this happening?
Thanks.
JB
One possibility is that mysql server & glassfish server are installed on the same host.
So, you should go to etc/mysql/my.cnf if there is a public ip address bind you should remove it and put only bind-address = 127.0.0.1
Another case is that in stead of URL: jdbc:mysql://localhost:3306/SIRS you should put
URL: jdbc:mysql://127.0.0.1:3306/SIRS
This worked for me.
I want to access sql database remotely from play framework version 1.2.4
I am running play in virtualbox and I have mysql database in local pc.
app/conf/application.conf
db.url=jdbc:mysql://xxx.xxx.47.78:3306/vedb
db.driver=org.postgresql.Driver
db.user=root
db.pass=aaa123aaa
/etc/mysql/my.cnf
bind-address=xxx.xxx.47.78
when I start the app with http://localhost:9000/ I am getting below error
A database error occured : Cannot connected to the database,
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.
In your example you define a mysql URL but set the driver to postgresql...
Try to comment the driver setting, or set it to: 'com.mysql.jdbc.Driver'
You can alos try to connect to your mysql server using the mysql command line:
mysql -h xxx.xxx.47.78 -u root -p
Then enter the root password (mysql root password). This will test the network connection to the mysql server.
I have a remote server say 1.2.3.4 where I run a code to connect to MySQL which is on another (third) remote server. Now the piece of code runs perfectly fine from my local machine (It connects to Mysql on the Remote server), and that piece of code runs well from two other different IP addresses also.
But only from 1.2.3.4 server when I try to connect to MySQL it gives this Error:
OperationalError: (2003, "Can't connect to MySQL server on '45.105.149.250' (110)")
What can be the Issue ?
Try telnet to the server port 3306 and see if it goes through.
That will tell you if it's MySQL that has the issue or something else.