Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TRIGGER AU_TRIGGER
- AFTER UPDATE ON TABLE_A FOR EACH ROW
- CALL "com.trigger.MyTrigger";
- LOAD DATA LOW_PRIORITY INFILE 'C:/Users/mytextfile.delim'
- REPLACE INTO TABLE TABLE_B
- FIELDS TERMINATED BY '|'
- IGNORE 1 LINES
- (name, age, etc);
- This is my application.yml spring.datasource.url
- =jdbc:h2:mem:mydb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=MYSQL
- spring.datasource.username: myusername
- spring.datasource.password: mypassword
- driver-class-name: org.h2.Driver
- @Bean
- public DataSource dataSource() throws SQLException {
- EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
- EmbeddedDatabase db = builder
- .setType(EmbeddedDatabaseType.H2)
- .setName("mydb;MODE=MYSQL")
- .addScript("mariadb.sql") //it has to be different than data.sql otherwise Springboot will pick data.sql automatically and this will also run.
- .build();
- return db;
- }
- @Bean
- @DependsOn("dataSource")
- public Void string(DataSource db) throws SQLException {
- //read file using whatever means. I used Scanner and delimeted it myself.
- List<List<String>> list = readFile();
- final Connection connection = db.getConnection();
- //here use the prepratedStatements
- PreparedStatement stmt = connection.prepareStatement(Insert xyz);//lookup how to use PreparedStatement.
- }
Add Comment
Please, Sign In to add comment