When I am running JUnits, those are executing fine in local but failing in Jenkins Pipeline with below error:
SQL State : 08001
Error Code : 0
Message : Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Below are pom.xml dependencies:
<!-- https://mvnrepository.com/artifact/com.wix/wix-embedded-mysql -->
<dependency>
<groupId>com.wix</groupId>
<artifactId>wix-embedded-mysql</artifactId>
<version>4.6.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.flywaydb/flyway-core -->
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
Properties of MySQL:
spring.jpa.database=mysql
spring.datasource.url=jdbc:mysql://localhost:2205/?autoReconnect=true&useSSL=false
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.main.allow-bean-definition-overriding=true
# HIBERNATE
spring.jpa.properties.hibernate.proc.param_null_passing=true
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
# FLYWAY
spring.flyway.enabled=true
spring.flyway.schemas=test
Can anyone please suggest why it failing with above error message when running Junits in Jenkins pipeline?
Related
In my Java Spring Boot project I try to migrate User entity into mysql database.
When I mvn spring-boot:run, I see following error:
HHH90000026: MySQL57Dialect has been deprecated; use org.hibernate.dialect.MySQLDialect instead
Here's my application.properties:
spring.datasource.url=jdbc:mysql://localhost:3306/mydb?createDatabaseIfNotExist=true
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.database=mysql
Here's the dependency for mysql:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
What am I missing?
With the help of Raushan Kumar I solved the connection problem with:
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
I am currently using the below properties to connect to localhost from Java spring boot application:
spring.jpa.hibernate.ddl-auto=create
spring.datasource.url=jdbc:sqlserver://localhost:1433;database=vlad;integratedSecurity=true
spring.jpa.properties.hibernate.format_sql=true
springdoc.api-docs.path=/api-docs
From Java spring boot this is not working. The error I get is:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
You will most likely need to configure your Dialect and Include a driver:
application.properties:
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2016Dialect
You will also most likely need to add driver and auth dependency to your pom.xml
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc_auth</artifactId>
<version>10.2.1.x86</version>
<type>dll</type>
</dependency>
If that doesn't do the trick, you might have to manually download the Driver:
https://learn.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-2017
Hope it helps
I'm trying to use Intersystems IRIS Database with
Quarkus, but I'm getting problems making it work
does anyone knows how to set up the Intersystems IRIS Database
on Quarkus ?
I did that on my pom.xml and also I added the jar
hibernate-iris-1.0.0.jar and intersystems-jdbc-3.2.0.jar but it's not working
<dependency>
<groupId>com.intersystems</groupId>
<artifactId>intersystems-jdbc</artifactId>
<version>3.2.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/intersystems-jdbc-3.2.0.jar</systemPath>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-iris</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/hibernate-iris-1.0.0.jar</systemPath>
</dependency>
This is my application.properties
quarkus:
datasource:
db-kind: other
username: _system
password: *****
jdbc:
url: jdbc:IRIS://localhost:1972/USER
driver: com.intersystems.jdbc.IRISDriver
hibernate-orm:
dialect: org.hibernate.dialect.InterSystemsIRISDialect
jdbc:
timezone: UTC
I found the solution, to set up Intersystems IRIS on Quarkus you need to add manually the jar file, and also you need to set up the pom.xml also some setup from Intersystems was made as a java class. you can see the solution looking at my project on GitHub
this is the link: https://github.com/JoseAdemar/quarkus-project-with-intersystems-ris-database
I have a spring boot project,It run just fine when I execute via eclipse Project > Run as > spring boot app
but when I build the project and execute it using java -jar myproject.jar or run it using mvn spring-boot:run it throw this error
Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource:
Property: driverclassname
Value: com.microsoft.sqlserver.jdbc.SQLServerDriver
Origin: "driverClassName" from property source "source"
Reason: Failed to load driver class com.microsoft.sqlserver.jdbc
.SQLServerDriver in either of HikariConfig class loader or Thread context classloader
Action:
Update your application's configuration
my sql server connector dependency
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.4.0.jre8</version>
<scope>test</scope>
</dependency>
and here my application.properties
spring.datasource.url=jdbc:sqlserver://mydb;databaseName=HTSdb
spring.datasource.username=xxx
spring.datasource.password=xxx
spring.jpa.show-sql=true
spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
it looks my app can't find the sqlserver driver but it is already in project classpath,any suggestion? thanks in advance
I think the issue is with dependency scope which is set as test.
Scope test indicates that dependency isn't required at standard runtime of application and should only be used for purpose of test runs only!
Usually database connectors dependency are set with runtime scope.
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.4.0.jre8</version>
<scope>runtime</scope>
</dependency>
Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource:
Property: driver-class-name
Value: org.postgresql.Driver
Origin: "driverClassName" from property source "source"
Reason: Failed to load driver class org.postgresql.Driver in either of HikariConfig
class loader or Thread context classloader
Action:
Update your application's configuration
Just had the same error, in my case with "org.postgresql.Driver".
Gues what was the issue? an empty space after "org.postgresql.Driver " by mistake.
So, be aware about that ' ' invisible empty space :).
Add dependency
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
check if Jar is loaded in lib if not then you need to add version 8.2.1.jre8 and rebuild the project .
You can validate by checking if mssql-jdbc-8.2.1.jre8 jar is there loaded in project and it has SQLServerDriver.class file in it .
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"