Thursday, July 25, 2013

Java to MySQL Database Connection with net beans IDE

Java to MySQL Database Connection with net beans IDE


package Utility;
/**
 *
 * @author Nazmus Sakib
 */

import java.sql.Connection;
import java.sql.DriverManager;
import javax.swing.JOptionPane;


public class javaconnect {
   
    Connection conn = null;
    public static Connection ConnecrDb(){
       
        try {
             Class.forName("com.mysql.jdbc.Driver");
             Connection conn = (Connection)DriverManager.getConnection("jdbc:mysql://localhost/dcl_payrole","root","123456");
             return conn;
        }catch (Exception e) {
           
            JOptionPane.showMessageDialog(null, e);
            return null;
            
        }
      
    }
   
}

2 comments:

  1. mentioning the versions of IDE and Jdk will make it more meaning full to the followers!! btw Great Job (Y)

    ReplyDelete
  2. NetBeans IDE 7.1.2 & JDK 1.6
    Thanks

    ReplyDelete