private JdbcTemplate getJdbcTemplateFromHisConfig(HisConfig hisConfig) {
if (hisConfig.getDbtype().equals("1")) {
JdbcTemplate jdbcTemplate = new JdbcTemplate();
HikariDataSource ds = new HikariDataSource();
ds.setJdbcUrl("jdbc:sqlserver://"+hisConfig.getIp()+":"+hisConfig.getPort()+";DatabaseName="+hisConfig.getDbname()+";autoReconnectForPools=true;encrypt=true;trustServerCertificate=true;");
ds.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
ds.setUsername(hisConfig.getDbUser());
ds.setPassword(hisConfig.getDbPassword());
jdbcTemplate.setDataSource(ds);
return jdbcTemplate;
}
if (hisConfig.getDbtype().equals("2")) {
JdbcTemplate jdbcTemplate = new JdbcTemplate();
DruidDataSource ds = new DruidDataSource();
ds.setDriverClassName("com.mysql.cj.jdbc.Driver");
ds.setUrl("jdbc:mysql://" + hisConfig.getIp() + ":" + hisConfig.getPort() + "/" + hisConfig.getDbname() + "?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8");
ds.setUsername(hisConfig.getDbUser());
ds.setPassword(hisConfig.getDbPassword());
jdbcTemplate.setDataSource(ds);
return jdbcTemplate;
}
if (hisConfig.getDbtype().equals("3")) {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName("oracle.jdbc.driver.OracleDriver");
dataSource.setUrl("jdbc:oracle:thin:@" + hisConfig.getIp() + "");
dataSource.setUsername(hisConfig.getDbUser());
dataSource.setPassword(hisConfig.getDbPassword());
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
return jdbcTemplate;
}
return null;
}