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;
}
}
}
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;
}
}
}
mentioning the versions of IDE and Jdk will make it more meaning full to the followers!! btw Great Job (Y)
ReplyDeleteNetBeans IDE 7.1.2 & JDK 1.6
ReplyDeleteThanks