I am not able to open H2 console on the web browser.
My jhipster application is running on 8088 port. In server logs I am getting that H2 database is available on port 18088.
Tried below.
http://localhost:18088/h2-console
Getting Below response.
Below are the details in application-dev.yml.
devtools:
restart:
enabled: true
additional-exclude: .h2.server.properties
livereload:
enabled: false # we use Webpack dev server + BrowserSync for livereload
jackson:
serialization:
indent-output: true
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:h2:mem:jhipstersampleapplication;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
username: jhipsterSampleApplication
password:
hikari:
poolName: Hikari
auto-commit: false
h2:
console:
enabled: true
jpa:
database-platform: io.github.jhipster.domain.util.FixedH2Dialect
database: H2
show-sql: true
properties:
hibernate.id.new_generator_mappings: true
hibernate.connection.provider_disables_autocommit: true
hibernate.cache.use_second_level_cache: true
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: false
Please Help me out with this.
Adding slash solved my problem http://localhost:8080/h2-console to http://localhost:8080/h2-console/
There are 2 different ports:
HTTP port 8088 for h2 web console, it's served by your web app (same as your REST API)
TCP port 18088 that can be used by other applications using JDBC, it can't be used from a browser. This port is opened in DatabaseConfiguration.java in your project
Go to root of the app url (Access Url that you see in the application start)
then type "/h2-console" in the end.
localhost:8081/services//h2-console
Ensure you are accessing the correct port (8088 in your case), and that you do not change jhipster's setting for h2.console.enabled.
http://localhost:8088/h2-console should work.
Related
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
I created a simple micronaut app in my local with 'consul-config' feature. My code can able to connect and get properties from consul key/value store. I have below configuration in my bootstrap.yml
micronaut:
application:
name: user-service
config-client:
enabled: true
consul:
client:
registration:
enabled: true
defaultZone: "${CONSUL_HOST:localhost}:${CONSUL_PORT:8500}"
Everything is fine but I don't want to use consul in my local computer, because since it involves the network activity so startup takes sometime. I want to avoid consul in local but I need it in dev, test and prod environments.
I have below code in my app. #Value annotation will try to load 'db-schema' and if it not founds then uses 'local' as default value. So if consul is disabled then my app should use 'local' else it should load values based on consul configuration.
#Value("${db-schema:local}")
private String dbSchema;
How I can do this with out code changes and only with environment options?
I tried setting VM option '-Dmicronaut.config-client.enabled=false' but still it loads bootstrap.yml and trying to connect consul.
There are a number of ways you can do it. One is to create a file like src/main/resources/application-local.yml which contains the following:
consul:
client:
registration:
enabled: false
And in your local environment export MICRONAUT_ENVIRONMENTS=local.
I have implemented an API gateway with Spring cloud gateway. I have added the Redis rate limiters with below configurations:
spring:
cloud:
gateway:
discovery:
locator:
enabled: true
routes:
- id: user-service
uri: lb://user-service
predicates:
- Path=/user/**
filters:
- StripPrefix=1
- name: RequestRateLimiter
args:
key-resolver: "#{#remoteAddrKeyResolver}"
redis-rate-limiter.replenishRate: 1
redis-rate-limiter.burstCapacity: 5
---
spring:
redis:
host: localhost
port: 6379
database: 0
I can successfully block the user requests with an error code 429 TOO Many requests.
Now, I want the same entry to be inserted into the Redis database so that I can analyze.
What configuration do I need to make?
I have visited a blog where he shows it but I couldn't find code related to it. Here is the a link to that blog.
Also, Can anyone explain the exact difference between replenishRate vs burstCapacity with some example? I am a bit confused here.
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.
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)