SHARE
TWEET

Untitled

a guest Sep 17th, 2019 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top