Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. package my.test;
  2.  
  3. import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
  4. import com.mysql.jdbc.log.Slf4JLogger;
  5. import org.testcontainers.containers.MySQLContainer;
  6.  
  7. import javax.sql.DataSource;
  8. import java.sql.SQLException;
  9.  
  10. public class TestClass {
  11.  
  12. public static void main(String[] args) throws SQLException {
  13. MySQLContainer container = new MySQLContainer() {{
  14. start();
  15. }};
  16. DataSource testDataSource = new MysqlDataSource() {{
  17. setURL(container.getJdbcUrl());
  18. setUser(container.getUsername());
  19. setPassword(container.getPassword());
  20. setLoggerClassName(Slf4JLogger.class.getName());
  21. setUseSSL(false);
  22. }};
  23. testDataSource.getConnection();
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement