Previn

Connect_MySql

Sep 18th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1.  
  2. import java.sql.Connection;
  3. import java.sql.DriverManager;
  4. import java.sql.PreparedStatement;
  5. import java.sql.ResultSet;
  6.  
  7.  
  8. public class Test_Database {
  9.  
  10.     public static void main(String[] args) {
  11.        
  12.         Connection con;
  13.         PreparedStatement ps;
  14.         ResultSet rs;
  15.        
  16.         try
  17.         {
  18.             Class.forName("com.mysql.jdbc.Driver");
  19.             con=DriverManager.getConnection("jdbc:mysql://localhost/","root",""); //check for running server
  20.             System.out.println("Server Connected");          
  21.            
  22.         }
  23.         catch(Exception e)
  24.         {
  25.             System.out.println(e);
  26.         }        
  27.     }    
  28. }
Add Comment
Please, Sign In to add comment