Advertisement
Guest User

Untitled

a guest
Mar 7th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import com.mysql.fabric.jdbc.FabricMySQLDriver;
  2. import com.mysql.jdbc.Connection;
  3. import java.sql.Driver;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. /**
  8. * Created by taras on 07.03.2016.
  9. */
  10. public class Main {
  11. private static final String URL = "jdbc:mysql://localhost:3306/library";
  12. private static final String USER = "root";
  13. private static final String PASSWORD = "root";
  14.  
  15. public static void main(String[] args){
  16. Connection connection;
  17. try {
  18. Driver driver = new FabricMySQLDriver();
  19. DriverManager.registerDriver(driver);
  20. connection = (Connection) DriverManager.getConnection(URL, USER, PASSWORD);
  21. if (!connection.isClosed()){
  22. System.out.println("MySQL");
  23. }
  24. connection.isClosed();
  25. if (!connection.isClosed()){
  26. System.out.println("Not MySQL");
  27. }
  28. } catch (SQLException e) {
  29. System.out.println("Error");
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement