Guest User

Untitled

a guest
Nov 12th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. package test;
  2.  
  3. import com.mysql.fabric.jdbc.FabricMySQLDriver;
  4.  
  5. import java.sql.*;
  6.  
  7. public class Main {
  8.  
  9. private static final String URL = "jdbc:mysql://localhost:3306/mydb_test";
  10. private static final String USERNAME = "root";
  11. private static final String PASSWORD = "root";
  12. public static void main(String[] args){
  13.  
  14. try {
  15. Driver driver = new FabricMySQLDriver();
  16. DriverManager.registerDriver(driver);
  17. }
  18. catch (SQLException e) {
  19. e.printStackTrace();
  20. }
  21. try(Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD); Statement statement = connection.createStatement() ) {
  22. System.out.println(connection.isClosed());
  23. }
  24. catch (SQLException e) {
  25. e.printStackTrace();
  26. }
  27. }
  28. }
  29. }
Add Comment
Please, Sign In to add comment