Grails + mysql : The driver has not received any packets from the server - java

I am attempting to connect my grails application to a Mysql database running locally via MAMP. I am getting the following error, and nothing else. I've tried every configuration. I don't think this is a Grails issue but more of a configuration issue. Any help would be most appreciated.
The driver has not received any packets from the server.
Here is my application.yml
environments:
development:
dataSource:
dbCreate: update
driverClassName: "com.mysql.jdbc.Driver"
dialect: org.hibernate.dialect.MySQL5Dialect
url: "jdbc:mysql://localhost:3306/development"
username: "root"
password: ""
I've tried with the port, without port different dialects and still no luck. Any ideas on what could be going on?
Thanks in advance for your help.

Related

Cant connect dockerized springboot application to not dockerized postgres database (localhost) [duplicate]

This question already has answers here:
From inside of a Docker container, how do I connect to the localhost of the machine?
(40 answers)
Closed 1 year ago.
Im getting the connection refused error, but in my eclipse it connects with no problem. I wonder if it is not possible to connect to a database that hasnt been dockerized also or if its possible what should I do?
thise is my Dockerfile:
FROM openjdk:11
EXPOSE 8080
ADD target/permisos.jar permisos.jar
ENTRYPOINT ["java","-jar","/permisos.jar"]
this is my application.yml file:
spring:
profiles:
active: local
jpa:
database: POSTGRESQL
show-sql: true
hibernate:
ddl-auto: none
datasource:
platform: postgres
url: jdbc:postgresql://localhost:5432/permisosdb
username: postgres
password: postgres
driverClassName: org.postgresql.Driver
The IP address of the host is host.docker.internal on, AFAIK, all modern Docker installations.
So your datasource URL should be
url: jdbc:postgresql://host.docker.internal:5432/permisosdb
If that doesn't work, try
url: jdbc:postgresql://172.17.0.1:5432/permisosdb

How to make Spring server to start even if database is down?

I'm using a Spring Boot(1.4.7) & MyBatis.
spring.main1.datasource.url=jdbc:mariadb://192.168.0.11:3306/testdb?useUnicode=true&characterEncoding=utf8&autoReconnect=true&socketTimeout=5000&connectTimeout=3000
spring.main1.datasource.username=username
spring.main1.datasource.password=password
spring.main1.datasource.driverClassName=org.mariadb.jdbc.Driver
spring.main1.datasource.tomcat.test-on-borrow=true
spring.main1.datasource.tomcat.test-while-idle=true
spring.main1.datasource.tomcat.validation-query=SELECT 1
spring.main1.datasource.tomcat.validation-query-timeout=5000
spring.main1.datasource.tomcat.validation-interval=5000
spring.main1.datasource.tomcat.max-wait=5000
spring.main1.datasource.continue-on-error=true
I cannot start program with errors when database is disconnected on Eclipse or Linux server.
(Database is not located on localhost.)
When I try to start program with disconnected database,
print this.
java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=192.168.0.11)(port=3306)(type=master) : connect timed out
Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=192.168.0.11)(port=3306)(type=master) : connect timed out
Stopping service [Tomcat]
Application startup failed
Is there any way?
Thanks
You can set:
spring.sql.init.continue-on-error=true
in your application.properties.
According to the Spring Boot 2.5.5 user guide:
By default, Spring Boot enables the fail-fast feature of its script-based database initializer. This means that, if the scripts cause exceptions, the application fails to start. You can tune that behavior by setting spring.sql.init.continue-on-error.
P.S.: Before Spring Boot 2.5, the property was named spring.datasource.continue-on-error.
I was able to solve this. One main difference between what I got working and the code in the question, though, is that I'm using Hikari instead of Tomcat for the connection pool.
These were the key settings I had to make:
spring.datasource.hikari.minimum-idle: 0
spring.datasource.hikari.initialization-fail-timeout: -1
spring.datasource.continue-on-error: true
spring.datasource.driver-class-name: org.postgresql.Driver
spring.jpa.database-platform: org.hibernate.dialect.PostgreSQLDialect
Setting minimum-idle to 0 allows Hikari to be happy without any connections.
The initialization-fail-timeout setting of -1 tells Hikari that I don't want it to get a connection when the pool fires up.
From the HikariCP documentation:
A value less than zero will bypass any initial connection attempt, and the pool will start immediately while trying to obtain connections in the background. Consequently, later efforts to obtain a connection may fail.
The continue-on-error setting true allows the service to continue even when encountering an error.
Both the driver-class-name and database-platform were required. Otherwise, Hikari tries to figure out those values by connecting to the database (during startup).
Just in case I'm missing something, though, here's my full Spring config:
spring:
application:
name: <redacted>
datasource:
url: <redacted>
username: <redacted>
password: <redacted>
driver-class-name: org.postgresql.Driver
hikari:
minimum-idle: 0
maximum-pool-size: 15
connection-timeout: 10000 #10s
idle-timeout: 300000 #5m
max-lifetime: 600000 #10m
initialization-fail-timeout: -1
validation-timeout: 1000 #1s
continue-on-error: true
jpa:
open-in-view: false
database-platform: org.hibernate.dialect.PostgreSQLDialect
And my project has the following Spring Boot dependencies:
org.springframework.boot:spring-boot
org.springframework.boot:spring-boot-actuator
org.springframework.boot:spring-boot-actuator-autoconfigure
org.springframework.boot:spring-boot-autoconfigure
org.springframework.boot:spring-boot-configuration-processor
org.springframework.boot:spring-boot-devtools
org.springframework.boot:spring-boot-starter
org.springframework.boot:spring-boot-starter-actuator
org.springframework.boot:spring-boot-starter-jdbc
org.springframework.boot:spring-boot-starter-jooq
org.springframework.boot:spring-boot-starter-json
org.springframework.boot:spring-boot-starter-logging
org.springframework.boot:spring-boot-starter-security
org.springframework.boot:spring-boot-starter-test
org.springframework.boot:spring-boot-starter-tomcat
org.springframework.boot:spring-boot-starter-validation
org.springframework.boot:spring-boot-starter-web
You need to add
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
in order to make it works
If the tips above didn't help and you use jpa, then set
spring.jpa.hibernate.ddl-auto=none
it worked for me.
When you build your app you can add that
mvn clean install -DskipTests
it will skip the tests of database connection
(-D is used to define a system property)

"Ping Connection Pool failed for MySQL. Communications link failure due to underlying exception" Glassfish 4

I followed this tutorial here:
Creating and configuring a MySQL DataSource in GlassFish Application Server
In step 10, The info I've provided as follow (assuming my database name is Jsf_demo):
DatabaseName: jsf_demo
Password: thehung1724 (this is my MySQL password)
URL: jdbc:mysql://localhost:3306/jsf_demo. Where jsf_demo is your database name.
Url: jdbc:mysql://localhost:3306/jsf_demo. Where jsf_demo is your database name.
ServerName: HUNG-PC (I saw in MySQL)
User: sa
After that, when I click Ping, i got error:
I already copied mysql-connector.jar file to lib folder.
Hope any suggestion to help me solve this problem.
Have you restarted your GlassFish, because it's required to get new changes applied.
FYI: here is a working tutorial regarding GlassFish connection pool, check that.
Edit: I suppose that few properties URL and URl can cause issue you are experiencing.

Connecting to a MSSQL server using LDAP on Ubuntu Linux

I'm trying to connect to a MS SQL Server, using a linux client. I've tried both SQuirreL and DBeaver, but having no luck in either case. I've tried a few different drivers.
The connection string I am given looks something like this:
jdbc:oracle:thin:#ldap://<server>:<port>/<database>,cn=OracleContext,dc=<specific_dc>,dc=<specifc_dc>,dc=<specific_dc>
This seems to be an invalid URL, and I've tried various combinations of things (like using jdbc:sqlserver:// ... protocol, etc. It doesn't seem to like the #ldap in the connection string, and I've replaced the commas with semicolons. But, I'm new to connecting to SQL Server, much less using LDAP.
Any thoughts/help?
Thanks!
For those who are using DBeaver the way to connect to the SQL Server Database with an AD user is using the jTDS driver.
I am using DBeaver 6.0 in Debian 9. The user is an AD user.
In order to connect to the SQL Server from Linux Debian using DBeaver
1.- Select SQL Server jTDS driver
2.- Enter the connection information
3.- Go to Driver Properties tab and add the domain, user, password
Just as a note, in some post I found that they needed to change the property USENTLMV2 to TRUE but it worked for me either by putting the USERTLNMV2 in true or false.
A problem that I found was that when I was trying to connect to the database using my user and password the next error was thrown:
This error was thrown because of my user was about to expire. I tried with another AD user and it could connect.
cts:
datasource:
url: jdbc:jtds:sqlserver://dbserver:1433;database=DB;domain=yourdomain.com;useNTLMv2=true
driver-class-name: net.sourceforge.jtds.jdbc.Driver
username: username
password: password
hikari:
connection-test-query: SELECT 1
maximumPoolSize: 2
minimumIdle: 1

Error while connecting to DB2 from JBoss Application Server

I'm trying to connect to the AS400 database DB2 from a Java application hosted in JBoss application server. But, I'm getting the below error when ever I run my application:
Apparently wrong driver class specified for URL: class: com.ibm.as400.access.AS400JDBCDriver, url: jdbc:as400://DBSYTEM;driver=toolbox;trace=false;errors=full;prefetch=true;naming=system;libraries=*LIBL
Has anyone ever faced similar problem before?
Thanks,
Veera.
I had exactly the same problem.
Setting connection-url as the following resolved the problem.
jdbc:as400://[systemname]/[schema];extended dynamic=true;package=jbpkg;package cache=true;package library=jboss;errors=full
From the connection URL in your question, I think you're using DB2 on AS/400.
Have you verified the existence of the correct classpath of IBM DB2 for AS/400 JDBC driver? The JDBC driver of IBM DB2 for AS/400 is not provided by JBoss Application Server, it's provided only from IBM.

Categories