Not able to connect to H2 database in Spring Boot - spring

I have the below in my yaml file.I keep getting the below error.how to resolve the below error.I am using latest spring boot version .
org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database
"C:/Users/mynname/test" not found, either pre-create it or allow
remote database creation (not recommended in secure environments)
[90149-214]
I can see the H2 console in http://localhost:8080/h2.But when i click on connect button i get the error.
spring:
h2:
console:
enabled: true
path: /h2
datasource:
url: jdbc:h2:mem:testdb
username: sa
password:
driverClassName: org.h2.Driver
jpa:
spring.jpa.database-platform: org.hibernate.dialect.H2Dialect
hibernate.ddl-auto: create

On the h2 console change the default ur that appears there (jdbc:h2:mem:test) to jdbc:h2:mem:testdb
And you should be able to connect

Related

Spring Boot Liquibase doesn't appear to support XML formatted changelog

spring-boot-starter-parent:2.7.5
I have configured the following in my src/main/resources/application.yml file:
spring:
liquibase:
change-log: classpath:/db/changelog/db.changelog-master.xml
---
spring:
config:
activate:
on-profile: prod
datasource:
driver-class-name: org.postgresql.Driver
url: ${DB_URL}
username: ${DB_USERNAME}
password: ${DB_PASSWORD}
Additionally, the following resource exists in the project repository:
src/main/resources/db/changelog/db.changelog-master.xml
I also have the following configured in src/test/resources/application.yml:
spring:
config:
activate:
on-profile: test
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
username: sa
password: sa
liquibase:
change-log: classpath:/db/changelog/db.changelog-master.xml
When I try to build this project the build fails with the following error message:
Liquibase failed to start because no changelog could be found at 'classpath:/db/changelog/db.changelog-master.yaml'
Is there some way to configure spring boot to allow an xml based liquibase changelog file? If so, what am I missing? Or does it only support the yaml format?
Your configurations seems valid, but some configuration still points to classpath:/db/changelog/db.changelog-master.yaml (based by on provided error message)
If there is no some typo, than may be you should look for this property in some other configuration (.properties files, command line arguments and other, see doc for all possible ways)

Quarkus Devservice for Oracle Database is not working

I am working on Quarkus Microservice application in which trying to use Quarkus Devservice to start Oracle DB with below configuration in application.yml file. But it's throwing exception.
application.yml:
quarkus:
datasource:
db-kind: oracle
username: root
password: password
devservices:
image-name: oracle
Exception:
Failed to load steps from class 'io.quarkus.devservice.oracle.deployment.OracleDevServicesProcessoer'

Spring cloud config not apply global configuration

I'm having a problem on spring cloud configuration 2020.0.3, spring boot 2.4.5 for details:
Yaml configuration file is following Multi-profile YAML documents
I have a configuration yaml file on the config server.
my_cofig.yaml
spring:
datasource:
url: "jdbc:mariadb://localhost:3306/default_db"
driver-class-name: org.mariadb.jdbc.Driver
username: my_db
password: 12345
---
spring:
profiles: dev
datasource:
url: "jdbc:mariadb://localhost:3306/dev_db"
I have loaded the config from the config server by browser, it's correct.
But:
When I run Spring application with specific configuration (e.g. dev), Spring application must not apply global configuration variables defined on configuration file from configuration server. It only loads dev's configuration variables.
bootstrap.yaml
server:
port: 8081
spring:
application:
name: auth-service
cloud:
config:
enabled: true
fail-fast: true
allow-override: true
profile: dev
uri: http://localhost:5000
Error detail:
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
Please help me, many thanks!
spring:
profiles:
This does not exist (it was deprecated if I am not mistaken). Please check the reference documentation.
I believe that what you are looking for is the following (reference documentation):
spring:
datasource:
url: "jdbc:mariadb://localhost:3306/default_db"
driver-class-name: org.mariadb.jdbc.Driver
username: my_db
password: 12345
---
spring:
config:
activate:
on-profile: dev
datasource:
url: "jdbc:mariadb://localhost:3306/dev_db"
Finaly, I solved the problem by upgrading spring boot version to 2.5.1
Thanks all

how to configure both mongodb and postgres in spring boot application.yml?

We have spring boot project , in which we need to use mongo and postgres , but i thought am failing in configuring mongo and postgres details applicaiton.yml , below my what i configured , can any one please help me
spring:
profiles: stage
data:
mongodb:
host: mongodb-host
port: 27017
password: password
username: username
authentication-database: database
database: database
datasource:
driver-class-name: org.postgresql.Driver
url: postgres-url
username: user-name
password: password
tomcat:
validation-interval: 30000
test-on-borrow: true
validation-query: SELECT 1
when i start my spring-boot application , it is failing to start with below error
Caused by: java.lang.IllegalArgumentException: jdbcUrl is required with driverClassName.
can any one please help
Solution 1: remove spring.datasource.driver-class-name property
Solution 2: rename the spring.datasource.url property to spring.datasource.jdbc-url.
For solution 1 Spring Boot will figure out the default driver class name based on the spring.datasource.url property value.

Change Spring JPA repository to one related to HIVE/HADOOP

I am working on a project integrating Hadoop, Hive and accessing it via Spring.
Currently my project works with a default Spring repository: "org.springframework.data.jpa.repository.support.SimpleJpaRepository#757b7c0a" but I would want to work with a repository able to understand HIVE queries.
For example, inserting a user into a HIVE database.
Actually I have a connection to HIVE in my project but everything is chaos and nothing works and I believe it is because the repository I am using is not the correct one.
So my question is ... how, where and what values to insert in order to change that repository for a Hive-friendly one ?
I have this in my application.yml:
spring:
profiles:
include: swagger, no-liquibase
devtools:
restart:
enabled: true
livereload:
enabled: false # we use gulp + BrowserSync for livereload
datasource:
type: org.springframework.jdbc.datasource.DriverManagerDataSource
url: jdbc:hive2://localhost:10000/default;DB_CLOSE_DELAY=0
username: catalin
password:
default-auto-commit: true
jpa:
show-sql: true
properties:
hibernate:
format_sql: true
mail:
host: localhost
port: 25
username:
password:
thymeleaf:
cache: false
liquibase:
contexts: hive
Thank you.

Resources