Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ResultDbLoader {
- private JdbcTemplate jdbcTemplate;
- private Gson gson = new Gson();
- public ResultDbLoader() {
- DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource();
- driverManagerDataSource.setUrl("jdbc:mysql://localhost:3306/surveys");
- driverManagerDataSource.setUsername("root");
- driverManagerDataSource.setPassword("de123456");
- driverManagerDataSource.setDriverClassName("com.mysql.jdbc.Driver");
- jdbcTemplate = new JdbcTemplate(driverManagerDataSource);
- }
- private Record createRecord(String[] csvLine, int townId) {
- int personId = Integer.valueOf(csvLine[0]);
- String q1 = csvLine[1];
- String q2 = csvLine[2];
- String q3 = csvLine[3];
- List<String> surveryAnswers = new ArrayList<>();
- surveryAnswers.add(q1);
- surveryAnswers.add(q2);
- surveryAnswers.add(q3);
- String surveryAnswersJson = gson.toJson(surveryAnswers);
- Record record = new Record();
- record.personId = personId;
- record.townId = townId;
- record.surveryAnswers = surveryAnswersJson;
- return record;
- }
- public void insertInputToDb(String csvFile, int townId){
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement