Guest User

Untitled

a guest
Feb 6th, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. package org.zerock.controller;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5.  
  6. import org.junit.Test;
  7.  
  8. public class MySQLConnectionTest {
  9. private static final String DRIVER = "com.mysql.jdbc.Driver";
  10. private static final String URL = "jdbc:mysql://127.0.0.1:3306/book_ex";
  11. private static final String USER = "root";
  12. private static final String PW = "1234";
  13.  
  14. @Test
  15. public void testConnection() throws Exception{
  16. Class.forName(DRIVER);
  17.  
  18. try(Connection con = DriverManager.getConnection(URL, USER, PW)){
  19. System.out.println(con);
  20. }catch(Exception e) {
  21. e.printStackTrace();
  22. }
  23. }
  24. }
Add Comment
Please, Sign In to add comment