I running spring boot and try to generate database, i have a access problem
Database is created but not foreign key
so i done:
GRANT ALL ON *.* TO 'dbuser#localhost';
flush privileges;`
launch spring boot application, but get this error about alter denied to dbuser
ALTER command denied to user 'dbuser'#'localhost' for table 'room_payment'
2015-07-16 12:04:28.099 ERROR 4550 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000388: Unsuccessful: alter table vehicle add constraint FK_2k13lq037sx9358mhlf9gfmsc foreign key (model_modelId) references model (model_id)
2015-07-16 12:04:28.100 ERROR 4550 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : ALTER command denied to user 'dbuser'#'localhost' for table 'vehicle'
2015-07-16 12:04:28.102 INFO 4550 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000232: Schema update complete
Wrong quoting:
GRANT ALL ON *.* TO 'dbuser#localhost';
^----------------^
Since the whole thing is quoted, that's just a username. You want
GRANT ALL ON *.* TO 'dbuser'#'localhost';
^-^
instead. Note the extra quotes.
Related
I am setting up a very basic Spring-Boot application, to serve some Access database content as a REST service.
After doing battle with getting the ucanaccess jar included in my classpath, now I'm having trouble getting it to connect to my access db.
My spring.datasource is set like this:
spring.datasource.jdbc-url=jdbc:ucanaccess://C:\\Users\\Owner\\Documents\\brigette.accdb;showSchema=true;memory=false
spring.datasource.dialect=net.ucanaccess.hibernate.dialect.UCanAccessDialect
The error I am getting is:
2020-04-08 09:01:28.534 INFO 20740 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-04-08 09:01:28.557 WARN 20740 --- [ main] o.h.e.j.e.i.JdbcEnvironmentInitiator : HHH000342: Could not obtain connection to query metadata : Failed to get driver instance for jdbcUrl=jdbc:ucanaccess://C:\Users\Owner\Documents\brigette.accdb;showSchema=true;memory=false
2020-04-08 09:01:28.563 WARN 20740 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [agency/newmeta/jsis/BackendDbConfig.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
2020-04-08 09:01:28.568 INFO 20740 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
The access database does exist in that location, but I do get the same error if I use a non-existant db.
HHH000342: Could not obtain connection to query metadata : Failed to get driver instance for jdbcUrl=jdbc:ucanaccess://C:\Users\Owner\Documents\lalala.accdb;showSchema=true;memory=false
and also if I use / instead of delimited :
HHH000342: Could not obtain connection to query metadata : Failed to get driver instance for jdbcUrl=jdbc:ucanaccess://C:/Users/Owner/Documents/brigette.accdb;showSchema=true;memory=false
What I am missing about setting up the conneciton string?
TIA
Brigette
I suggest you to use another approach: use spring jpa with hibernate.
And follow the article:
Accessing MS Access with Hibernate 5 and Spring Boot
At the end of the day it will guide you to implement a little app to read and update an accdb database.
The important thing to point out is the "patch" included in the source code that must be used in your code (without it , your app will never work).
The "patch" is the hibernate dialect: it is very important, it is reported in the source code of the article and shared at the end of the article.
I have a user with role manager in jhipster, and this role should have the authority to create users.
I have implemented all front end functionality to allow this user to create users in user management. In admin.route.ts I provided the ROLE_MANAGER authority and in the canActivate method in user-management.component I gave the authority ROLE_MANAGER. I have also given permission .HasAnyAUthoirty() for both admin and manager roles in the /management/** APIs from the SecurityConfiguration class.
However, when I try open the user-management page,even though it opens, I see a message on top which says you are not authorized to see this page. THen when I create the user, I get the error
Enter: io.xiges.asbestos.adm.repository.CustomAuditEventRepository.add() with argument[s] = [AuditEvent [timestamp=2019-03-11T21:40:58.263Z, principal=user, type=AUTHORIZATION_FAILURE, data={type=org.springframework.security.access.AccessDeniedException, message=Access is denied}]]
2019-03-12 08:40:58.267 DEBUG 25632 --- [ XNIO-2 task-24] i.x.a.adm.aop.logging.LoggingAspect : Exit: io.xiges.asbestos.adm.repository.CustomAuditEventRepository.add() with result = null
2019-03-12 08:40:58.269 WARN 25632 --- [ XNIO-2 task-24] o.z.p.spring.web.advice.AdviceTrait : Forbidden: Access is denied
2019-03-12 08:40:58.272 WARN 25632 --- [ XNIO-2 task-24] .m.m.a.ExceptionHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.security.access.AccessDeniedException: Access is denied.
In my application, I want to give all users in the role manager, the authority to create users. What am I missing here?
I ran in a weird situation I never had before.
I've got a spring boot application running on intelliJ on ubuntu 18.
My spring boot application runs in a dev environment connected to a h2 in memory database. I have a session based login with spring security.
The weird thing is if after I stopped and restarted the application I am still logged in. And even if I completely restart IntelliJ the session is not cleared. Even the database keeps its state and is not getting dropped.
Only if I restart the whole system everything will be cleared.
Inside my application.properties there are no special properties set.
Everything's on default.
If I stop the application the following console output comes up:
2018-12-22 11:11:19.385 INFO 10000 --- [ Thread-35] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#73abcbfa: startup date [Sat Dec 22 11:11:00 CET 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#12e6f48a
2018-12-22 11:11:19.391 INFO 10000 --- [ Thread-35] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2018-12-22 11:11:19.391 INFO 10000 --- [ Thread-35] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans
2018-12-22 11:11:19.395 INFO 10000 --- [ Thread-35] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2018-12-22 11:11:19.395 INFO 10000 --- [ Thread-35] .SchemaDropperImpl$DelayedDropActionImpl : HHH000477: Starting delayed drop of schema as part of SessionFactory shut-down'
2018-12-22 11:11:19.415 WARN 10000 --- [ Thread-35] o.s.b.f.support.DisposableBeanAdapter : Invocation of destroy method failed on bean with name 'inMemoryDatabaseShutdownExecutor': org.h2.jdbc.JdbcSQLException:Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-197]
2018-12-22 11:11:19.417 INFO 10000 --- [ Thread-35] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2018-12-22 11:11:19.419 INFO 10000 --- [ Thread-35] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
Process finished with exit code 130 (interrupted by signal 2: SIGINT)
https://github.com/spring-projects/spring-boot/wiki/spring-boot-1.3.0-m3-release-notes
Update Tomcat, Jetty and Undertow to serialize session data when the
application is stopped and load it again when the application
restarts. Persistent session are opt-in; either by setting
persistentSession on the ConfigurableEmbeddedServletContainer or by
using the property server.session.persistent=true (Persistent sessions
are enabled by default with Devtools).
In spring boot 2, the property is:
server.servlet.session.persistent=false # Whether to persist session data between restarts.
I suppose you are talking about web login via browser (or REST-client). Also I suppose you're using default web security settings.
Then your login request creates a cookie with session id which is returned to browser and is being used in next requests until you close browser.
I'm struggling to understand if I can import the data defined inside my schema.sql and data.sql into a specific H2 database.
I use Spring Boot 2.0.6 and this is the configuration inside my application.properties:
# H2
spring.h2.console.enabled=true
spring.h2.console.path=/h2
# Datasource
spring.datasource.url=jdbc:h2:mem:assignment
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
And I correctly placed both schema.sql and data.sql inside the resources folder.
The application starts up correctly and imports the files:
2018-10-26 20:39:24.834 INFO 9448 --- [main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from URL [file:/C:/Users/Gabriele/code/java/assignment/target/classes/schema.sql]
2018-10-26 20:39:24.848 INFO 9448 --- [main] o.s.jdbc.datasource.init.ScriptUtils : Executed SQL script from URL [file:/C:/Users/Gabriele/code/java/assignment/target/classes/schema.sql] in 13 ms.
2018-10-26 20:39:24.850 INFO 9448 --- [main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from URL [file:/C:/Users/Gabriele/code/java/assignment/target/classes/data.sql]
2018-10-26 20:39:24.868 INFO 9448 --- [main] o.s.jdbc.datasource.init.ScriptUtils : Executed SQL script from URL [file:/C:/Users/Gabriele/code/java/assignment/target/classes/data.sql] in 18 ms.
But when I open the browser console, the assignment database is empty
while the test one is not.
What am I missing?
I managed to log prepared statements executed by Spring Batch using:
logging.level.org.springframework.jdbc=DEBUG
But this won't show regular statements given to a JdbcCursorItemReader.
I tried adding:
logging.level.java.sql=DEBUG
logging.level.java.sql.Connection=DEBUG
logging.level.java.sql.Statement=DEBUG
logging.level.java.sql.PreparedStatement=DEBUG
logging.level.java.sql.ResultSet=DEBUG
But this didn' t do the trick.
Spring Batch uses JDBC, so adding the configuration below in your configuration enables SQL logging:
logging:
level
org.springframework.jdbc.core.JdbcTemplate: debug
And this is a sample output:
2021-01-19 14:51:37.570 DEBUG 14792 --- [ main] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2021-01-19 14:51:37.571 DEBUG 14792 --- [ main] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT VERSION FROM BATCH_JOB_EXECUTION WHERE JOB_EXECUTION_ID=?]
Package for JdbcCursorItemReader is org.springframework.batch.item.database.
Change your conf accordingly:
logging.level.org.springframework.batch.item.database=DEBUG