Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package my.test;
- import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
- import com.mysql.jdbc.log.Slf4JLogger;
- import org.testcontainers.containers.MySQLContainer;
- import javax.sql.DataSource;
- import java.sql.SQLException;
- public class TestClass {
- public static void main(String[] args) throws SQLException {
- MySQLContainer container = new MySQLContainer() {{
- start();
- }};
- DataSource testDataSource = new MysqlDataSource() {{
- setURL(container.getJdbcUrl());
- setUser(container.getUsername());
- setPassword(container.getPassword());
- setLoggerClassName(Slf4JLogger.class.getName());
- setUseSSL(false);
- }};
- testDataSource.getConnection();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement