Guest User

sms

a guest
Jul 7th, 2017
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. package db;
  2.  
  3. import java.sql.*;
  4.  
  5. public class DBConnection {
  6.    
  7.  
  8.     static Connection conn;
  9.  
  10.     public static Connection getConnection()
  11.     {
  12.         try
  13.         {
  14.    
  15.    
  16.          
  17.             Class.forName("com.mysql.jdbc.Driver");
  18.             try
  19.             {
  20.                 /* String url = "jdbc:mysql://localhost:3306/blewsrms";
  21.              String uname = "root";
  22.              String pwd = "root";
  23.              */
  24.             String url = "jdbc:mysql://localhost:3306/bleweduc_sms";
  25.         String uname = "bleweduc_abc";
  26.         String pwd = "abc@123";
  27.                    
  28.                 conn = DriverManager.getConnection(url,uname,pwd);
  29.                 System.out.println("connection Successfull");
  30.             }
  31.             catch (SQLException ex)
  32.             {
  33.                 ex.printStackTrace();
  34.             }
  35.         }
  36.         catch(ClassNotFoundException e)
  37.         {
  38.             System.out.println(e);
  39.         }
  40.         return conn;
  41.     }
  42.  
  43. }
Add Comment
Please, Sign In to add comment