Advertisement
Guest User

Untitled

a guest
May 13th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. import java.sql.*;
  2.  
  3.  
  4.  
  5. class testConnection
  6. {
  7.     public static void main(String args[])
  8.     {
  9.     Connection con = null;
  10.  
  11.     System.out.println("Connecting...");
  12.     try {
  13.       Class.forName("com.mysql.jdbc.Driver").newInstance();
  14.       con = DriverManager.getConnection("jdbc:mysql://cs10360.flosoft-servers.net:3306/project",
  15.         "csproject", "hb4R9nYytU588t2v");
  16.  
  17.       if(!con.isClosed())
  18.         System.out.println("Successfully connected to " +
  19.           "MySQL server using TCP/IP...");
  20.  
  21.     } catch(Exception e) {
  22.       System.err.println("Exception: " + e.getMessage());
  23.       e.printStackTrace();
  24.     } finally {
  25.       try {
  26.         if(con != null)
  27.           con.close();
  28.       } catch(SQLException e) {}
  29.     }
  30.   }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement