Spring boot configuration custom sql - spring-boot

I am trying to play with oracle edition views using spring data jpa and everything works fine.
The problem is if we can configure the specific oracle views in spring boot. Is this possible and how?
Thanks for your help in advance.
Vicky

It was very easy which I overlooked.. during the data source creaion we can pass the SQL that we need to trigger... This helped me load views..

Related

what is the best way to create session from java spring boot using oracle Database?

I created user in oracle database and I am trying to create session but I find many ways in spring boot so what is the easy way if I want to create classe connections using the Username and Password ?
You can jdbc template, spring data JDBC or spring data JPA, well depending on your use case.
If your data model is quite complex, you should avoid using the JDBC template as you will need to write prepared statements which can be cumbersome. JPA will allow you to use object-oriented programming principles and also will help you map the entities to your database columns.
For example, if you are going to use spring data JPA, you need to set the application properties as follows:
spring.datasource.type=oracle.oracleucp.jdbc.UCPDataSource
spring.datasource.oracleucp.connection-factory-class-name=oracle.jdbc.pool.OracleDataSource
spring.datasource.oracleucp.sql-for-validate-connection=select * from dual
spring.datasource.oracleucp.connection-pool-name=UcpPoolBooks
spring.datasource.oracleucp.initial-pool-size=5
spring.datasource.oracleucp.min-pool-size=5
spring.datasource.oracleucp.max-pool-size=10
This would behind the scene create an Oracle Datasource. In this example, we are using Oracle Universal Connection Pooling. You can also use HikariCP which is quite popular.
check this out
If you want to use UCP with above properties then you must have SpringBoot version higher than 2.4.0.
Check out the Spring Boot code sample on GitHub.

small emebedded database for spring data

I try to write a small web application with a restfull frontend to manage a little amount of data (round about 30 datasets). I want to create a PDF file from the datasets (using iText, but this is not the Problem). I search now a small database, which I can embed in my application an which persists the data somewhere on my Harddisc (if possible no Client / Server database), but I find no example / tutorial for this. All tutorial I found using a database in in-Memory mode, which is not what I need. Is there somewhere a nice tutorial helping me? Which database would you sugest to use in my Situation?
Thanks for your help and
Kind regards,
Andreas Grund
You can use H2, HSQL and Derby databases for embedded database. For example h2 database datasource-url like below :
jdbc:h2:~/Desktop/Database/test;DB_CLOSE_ON_EXIT=FALSE;
And in spring boot you can easily do it ,if you read this document Spring Boot-Embedded Databases

Spring Boot Application add datasource at runtime?

I working on a project which uses Spring boot , Spring Data JPA and postgres .There is a problem that can't solve .
When my application start up ,The database not ready yet . It need to add to application at runtime . But I also want to initialize a database using JPA.
just like spring.jpa.hibernate.ddl-auto:create-drop,Unfortunately Initialize a database using JPA will happen at application startup.
My question is that how to delay spring data jpa DDL generation. now we can't add a datasource at application runtime.
I am searching for a long time on net. But no use. The AbstractRoutingDataSource may be not suit for us, because we don't have a datasource at begin .
Please help or try to give some ideas how to achieve this
Thanks in advance
AbstractRoutingDataSource is not useful as it requires pre-configured datasources.
just check this stackoverflow question, it shows how you can add/remove datasources at runtime. While it doesn't support hibernate's delayed ddl creation but you can create database tables in runtime datasources using schema.sql and inserts some constants using data.sql.

Spring kundera cassandra

Is it possibility to populate database after auto creating with Kundera?
I have prepared import.cql file with required data for application and need something like
<property name="hibernate.hbm2ddl.import_files" value="import.sql"/>
Thanks for advance
No, you have to manually run these scripts to create application data. Only Schema Generation using Kundera is possible.

Edit a record from a DB table using EJB3?

im quite new to EJB3 and was wondering if it is possible to edit a specific record from a table using EJB3?
If so, are there any tutorials and examples on how to do this?
Thanks in advance
Since entity beans were deprecated in the EJB3 standatd, you'd do this using either plain JDBC or JPA, but neither of these requires EJBs to be used.

Resources