Guest User

Untitled

a guest
Oct 29th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. CREATE TRIGGER AU_TRIGGER
  2. AFTER UPDATE ON TABLE_A FOR EACH ROW
  3. CALL "com.trigger.MyTrigger";
  4.  
  5. LOAD DATA LOW_PRIORITY INFILE 'C:/Users/mytextfile.delim'
  6. REPLACE INTO TABLE TABLE_B
  7. FIELDS TERMINATED BY '|'
  8. IGNORE 1 LINES
  9. (name, age, etc);
  10.  
  11. This is my application.yml spring.datasource.url
  12. =jdbc:h2:mem:mydb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=MYSQL
  13. spring.datasource.username: myusername
  14. spring.datasource.password: mypassword
  15. driver-class-name: org.h2.Driver
  16.  
  17. @Bean
  18. public DataSource dataSource() throws SQLException {
  19. EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
  20. EmbeddedDatabase db = builder
  21. .setType(EmbeddedDatabaseType.H2)
  22. .setName("mydb;MODE=MYSQL")
  23. .addScript("mariadb.sql") //it has to be different than data.sql otherwise Springboot will pick data.sql automatically and this will also run.
  24. .build();
  25. return db;
  26. }
  27.  
  28. @Bean
  29. @DependsOn("dataSource")
  30. public Void string(DataSource db) throws SQLException {
  31. //read file using whatever means. I used Scanner and delimeted it myself.
  32. List<List<String>> list = readFile();
  33. final Connection connection = db.getConnection();
  34. //here use the prepratedStatements
  35. PreparedStatement stmt = connection.prepareStatement(Insert xyz);//lookup how to use PreparedStatement.
  36. }
Add Comment
Please, Sign In to add comment