Java examples for JDBC:MySQL
Connect to Mysql database
import java.sql.Connection; import java.sql.DriverManager; public class config { Connection con = null;/* ww w .j a va2 s . co m*/ public Connection getcon() { try { Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/recruitmentsystem", "root", "root"); } catch (Exception e) { e.printStackTrace(); } return con; } public static void main(String[] args) { config c = new config(); Connection con1 = c.getcon(); System.out.println("Connection is:" + con1); } }