Thursday, 26 February 2015

MySQL Database Connection


MySQL Database Connection 



import java.sql.*;
/**
 *
 * @author Rajkumar
 */
public class ConnectionConfiguration {
     //public static final String URL = "jdbc:mysql://localhost:3306/passerin_crm";
   public static final String URL = "jdbc:mysql://localhost:3306/demopasserine_crm";
//    /**
//     * In my case username is "root" *
//     */
    public static final String USERNAME = "root";
//    /**
//     * In my case password is "1234" *
//     */
    public static final String PASSWORD = "root";
//
  //  public static final String URL = "jdbc:mysql://passerinegroup.com:3306/passerin_crm";
    /**
     * In my case username is "root" *
     */
 //   public static final String USERNAME = "passerin_crm";
    /**
     * In my case password is "1234" *
     */
  //  public static final String PASSWORD = "crm@!@#";
//////
   
    public static Connection getConnection() {
        Connection connection = null;

        try {
             Class.forName("com.mysql.jdbc.Driver");
             System.out.println("Connectinggggggg.....");
             connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
             System.out.println("Connected..");
           
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

        return connection;
    }

}

0 comments:

Post a Comment