Initialize schema for in-memory database? - spring-boot

using latest Spring boot as of time of this writing 3.0.2.
Cannot seem to start in memory database with SpringBatch.
org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "BATCH_JOB_EXECUTION" not found (this database is empty); SQL statement:
SELECT JOB_EXECUTION_ID, START_TIME, END_TIME, STATUS, EXIT_CODE, EXIT_MESSAGE, CREATE_TIME, LAST_UPDATED, VERSION from BATCH_JOB_EXECUTION E where JOB_INSTANCE_ID = ? and JOB_EXECUTION_ID in (SELECT max(JOB_EXECUTION_ID) from BATCH_JOB_EXECUTION E2 where E2.JOB_INSTANCE_ID = ?) [42104-214]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:502) ~[h2-2.1.214.jar:2.1.214]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477) ~[h2-2.1.214.jar:2.1.214]
at org.h2.message.DbException.get(DbException.java:223) ~[h2-2.1.214.jar:2.1.214]
at org.h2.message.DbException.get(DbException.java:199) ~[h2-2.1.214.jar:2.1.214]
at org.h2.command.Parser.getTableOrViewNotFoundDbException(Parser.java:8385) ~[h2-2.1.214.jar:2.1.214]
at org.h2.command.Parser.getTableOrViewNotFoundDbException(Parser.java:8369) ~[h2-2.1.214.jar:2.1.214]
at org.h2.command.Parser.readTableOrView(Parser.java:8358) ~[h2-2.1.214.jar:2.1.214]
I have this in my yaml:
server:
port: 8091
spring:
datasource:
url: jdbc:h2:mem:job-db
username: sa
password: password
jpa:
database-platform: org.hibernate.dialect.H2Dialect
hibernate:
show-sql: true
h2:
console:
enabled: true
integration:
jdbc:
initialize-schema: embedded
batch:
jdbc:
initialize-schema: always
job:
enabled: false

The mistake was that I placed #EnableBatchProcessing in config class. I think this was required with prior versions of Boot.

Related

In memory Derby Db, not loading initial scripts

using spring boot + with Derby depedency, and with below configuration. dont see scripts getting loaded
datasource:
url: jdbc:derby:memory:testdb;create=true
driverClassName: org.apache.derby.jdbc.EmbeddedDriver
username: app
#password:
generate-unique-name: false
continue-on-error: false
#schema: sql/initial-schema.sql
initialization-mode: always
data: sql/initial-data.sql
#schema: classpath:initial-schema.sql
#data: classpath:initial-data.sql
jpa:
defer-datasource-initialization: true
database-platform: org.hibernate.dialect.DerbyTenSevenDialect
generate-ddl: true
database: default
show-sql: true
hibernate:
naming:
strategy: org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
ddl-auto: **update**

Jhipster / Oracle connectivity steps ? dev database?

I tried many ways to generate Jhipster app with oracle as DEV_DATABASE_TYPE.
still not succeed and i can't find the steps to follow.
Tested with Jhipster 11g2 and 12c2, non of it worked.
Steps i followed :
Generate and app using JDL fil : app.jdl
application {
config {
applicationType monolith,
baseName jhipsterSampleApplication,
packageName io.company.crud,
authenticationType jwt,
databaseType sql,
prodDatabaseType oracle,
devDatabaseType oracle,
buildTool maven,
searchEngine false,
testFrameworks [gatling, protractor],
clientFramework angularX,
clientTheme Litera,
clientThemeVariant Light,
enableTranslation true,
nativeLanguage en,
languages [ en, fr ]
}
entities *
}
Then i update these files : application-dev.yml and pom.xml
spring:
profiles: dev
datasource:
driverClassName: oracle.jdbc.OracleDriver
dataSourceClassName: oracle.jdbc.pool.OracleDataSource
url: jdbc:oracle:thin:#localhost:1521:orcl
username: rest_test
password: rest_test
jpa:
database-platform: org.hibernate.dialect.Oracle10gDialect
database: ORACLE
openInView: false
show_sql: true
generate-ddl: false
hibernate:
ddl-auto: none
naming-strategy: org.hibernate.cfg.EJB3NamingStrategy
properties:
hibernate.cache.use_second_level_cache: true
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: false
hibernate.cache.region.factory_class: org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
I tried to delete this line from app.jdl :
prodDatabaseType oracle,
and i got an error saying : Only 'h2Memory', 'h2Disk', 'mysql' are allowed as devDatabaseType
Does anyone have a clear process to follow, in order to generate an app with Oracle DB ?
Thank you
This question was resolved here : stackoverflow.com/questions/60640151/jhipster-and-oracle-11gr2 thank you all

Symfony connect to oracle oci8

I'm on Symfony and I can't connect to a Oracle database, but I don't know why. Maybe you can help me a little.
Here my doctrine.yaml
doctrine:
dbal:
default_connection: default
connections:
default:
# configure these for your database server
url: '%env(DATABASE_URL)%'
server_version: '5.7'
charset: utf8mb4
test:
# configure these for your database server
url: '%env(DATABASE_TEST_URL)%'
driver: 'oci8'
server_version: ~
charset: utf8mb4
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
test:
connection: test
mappings:
test:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/Test'
prefix: 'App\Entity\Test'
alias: Test
My .env file with 2 database:
DATABASE_URL=mysql://xxx:xxx#mysql:3306/pivot
DATABASE_TEST_URL=//user:owd#host:port/dbname
And here my controller
public function xxx() {
$entityManager = $this->getDoctrine()->getConnection('test');
$sql = 'SELECT * FROM xxx.O2_ADRESSE WHERE ROWNUM = 1';
$stmt = $entityManager->prepare($sql);
$stmt->execute();
dump($stmt->fetchAll());
}
I get the following error :
An exception occurred in driver: ORA-12505: TNS:listener does not currently know of SID given in connect descriptor
Any help on what im doing wrong?
Are you sure that the db is running?
You can check it via sqlplus, eg:
sqlplus user:password#mysql:3306/pivot
Can you update DATABASE_URL and try?
to use oracle: DATABASE_URL="oci8://db_user:db_password#127.0.0.1:1521/db_name"
https://symfony.com/doc/current/doctrine.html
https://symfony.com/doc/current/bundles/DoctrineBundle/configuration.html#oracle-db

H2 Database Run Script First before Creating the Schema

I am trying to use the in-memory database H2 for some testing, In my case I am trying to Create the Schema and load the Schema with some data.
The problem that I am having is when I run a test it tries to run the script first without creating the schema and I get the errror table does not exists.
application-test.yml file
spring:
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:test;MODE=MySQL;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;INIT=CREATE SCHEMA IF NOT EXISTS sample\;runscript from '~/LoadData.sql'
jpa:
hibernate:
ddl-auto: create-drop
properties:
hibernate:
default_schema: sample
application.yml
server:
port: 0
spring:
application:
name: services
devtools:
livereload:
enabled: false
jpa:
show-sql: true
properties:
hibernate:
dialect: org.hibernate.dialect.MySQLDialect
default_schema: ${APP_DATASOURCE_SCHEMA}
temp:
use_jdbc_metadata_defaults: false
hibernate:
naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
jackson:
serialization:
indent-output: true
logging:
level:
com.application: DEBUG
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
instance:
leaseRenewalIntervalInSeconds: 3
leaseExpirationDurationInSeconds: 4
sample:
application:
portrange:
min: 8090
max: 8099
sendemail: false
ldap:
contextSource:
url: ${LDAP_URL}
base: ${LDAP_BASE}
userDn: ${LDAP_USER_DN}
password: ${LDAP_PASSWORD}

Cannot Connect Spring Boot Application to IBM Informix Database

I cannot connect my spring boot application to IBM Informix database. I have added the informix data source in application.yml file.
I am using spring 4.
I get the following error.
no writeable property 'url' in class com.informix.jdbcx.IfxXADataSource
spring.profiles.active: db_dummy
spring.mvc.view:
prefix: /WEB-INF/jsp/
suffix: .jsp
spring.messages.basename: static/resources/messages/pjMessageResource, static/resources/messages/pymacMessageResource, static/resources/messages/messageResource, static/resources/messages/base
spring.datasource:
url: jdbc:informix-sqli://x.x.x.x:9093/testdb:informixserver=myserver;
driverClassName: com.informix.jdbc.IfxDriver
username: informix
password: sss
xa:
dataSourceClassName: com.informix.jdbcx.IfxXADataSource
#----------------------------------------------------------
security.basic.enabled: false
spring.jackson.serialization.INDENT_OUTPUT: true
server.error.whitelabel.enabled: false
management:
context-path: /_mep
security.enabled: false
#security.role: SUPERUSER
multipart.maxFileSize: 10Mb
spring:
jpa:
openInView: true
show-sql: false
properties:
hibernate:
connection.charSet: UTF-8
format_sql: true
use_sql_comments: true
jdbc:
batch_size: 30
fetch_size: 100
jadira:
usertype:
autoRegisterUserTypes: true
javaZone: jvm
databaseZone: jvm
---
#----------------------------------------------------------------
# development
#----------------------------------------------------------------
spring.profiles: development
secondary.datasource:
url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
driverClassName: org.h2.Driver
username: sa
password:
xa:
dataSourceClassName: org.h2.jdbcx.JdbcDataSource
#----------------------------------------------------------
---
#----------------------------------------------------------------
# staging or production
#----------------------------------------------------------------
spring.profiles: staging,production
spring.jpa.database_platform: org.hibernate.dialect.InformixDialect
---
#----------------------------------------------------------------
# psql
#----------------------------------------------------------------
spring.profiles: informix
spring.datasource:
url: jdbc:informix-sqli://x.x.x.x:9093/aaa:informixserver=test;
driverClassName: com.informix.jdbc.IfxDriver
username: informix
password:
xa:
dataSourceClassName: com.informix.jdbcx.IfxXADataSource
---
#----------------------------------------------------------------
# h2
#----------------------------------------------------------------
spring.profiles: h2
spring.datasource:
url: jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
driverClassName: org.h2.Driver
username: sa
password:
xa:
dataSourceClassName: org.h2.jdbcx.JdbcDataSource
have you included the jars named 1)ifxjdbc & 2)ifxjdbcx jars.
in pom add Informix with releated versionID as dependencies.
<dependency>
<groupId>com.ibm.informix</groupId>
<artifactId>jdbc</artifactId>
<version>{versionID}</version>
</dependency>

Resources