자바8 에서 추가
@Component
public class H2Runner implements ApplicationRunner {
@Autowired
DataSource dataSource;
@Override
public void run(ApplicationArguments args) throws Exception {
try(Connection connection = dataSource.getConnection()) {
String url = connection.getMetaData().getURL();
String userName = connection.getMetaData().getUserName();
System.out.println(url);
System.out.println(userName);
Statement statement = connection.createStatement();
String sql = "CREATE TABLE USER(ID INTEGER NOT NULL, name VARCHAR(255), PRIMARY KEY (id))";
statement.executeUpdate(sql);
}
}
}