Open djangofan opened 11 months ago
Here is what I tried, but it doesn't work fo rme. :
then add this class to both Mvn task projects:
@Configuration
public class DataSourceConfig {
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("org.mariadb.jdbc.Driver");
dataSource.setUrl("jdbc:mariadb://localhost:3306/jsoncopy");
dataSource.setUsername("root");
dataSource.setPassword("pass");
return dataSource;
}
}
After doing this, the billsetuptask
will pass and appears to work but the billrun
task fails , with the following error:
Caused by: org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ?]; nested exception is java.sql.SQLSyntaxErrorException: (conn=146) Table 'jsoncopy.BATCH_JOB_INSTANCE' doesn't exist Caused by: java.sql.SQLSyntaxErrorException: (conn=146) Table 'jsoncopy.BATCH_JOB_INSTANCE' doesn't exist
My code example that reproduces this is here: https://github.com/djangofan/spring-cloud-data-example-0
HI @djangofan , Glad you are continuing your SCDF adventure!
Does the jsoncopy.BATCH_JOB_INSTANCE
exist? SCDF bootstrap that using Flyway (see src/main/java/org/springframework/cloud/dataflow/server/db/migration/db2/V1__Initial_Setup.java
). My guess is that it bootstrapped it before using a diff db than jsoncopy so did not do it once you switched to jsoncopy.
Ah ok. I've used FlyWay a lot but because I didn't see it in the pom anywhere, I wouldn't have guessed that is how you had it setup. If the pom.xml
had a FlyWay config in it, then I would have got it right away.
The tests pass and when the tests run I do see FlyWay running BUT it is not apparent how FlyWay is loading due to the word FlyWay not appearing anywhere in this source code.
I'll probably be able to eventually figure this out, but wanting help since it is not documented well.
The enablement of this seems to be related to these application.properties settings? This is my best guess as I start to investigate.
spring.datasource.initialization-mode=always
spring.batch.initialize-schema=always
I am close:
On Windows
On Mac, 2 problems:
My question should be a simple one: How can I convert batch/batchsamples to use MariaDB instead of H2?
When I run the
mvn clean install
, the tests use a embedded H2 database to do the copy from CSV into H2 tableI just want to convert it to using my MariaDB Docker instance instead.
Is this an easy change? I tried to put datasource properties in the
application.properties
files BUT it didn't work. Looks like it's not that simple. Also,billsetuptask
seems to fail at creating the table: BILL_STATEMENTS