Basic Database Connectivity Using JDBC

First you must download the Connector/J driver from internet that will be used to assist connectivity.

JDBC is a program or software component or Database Connectivity API to enable Java application in interaction with a database. JDBC drivers are analogous to ADO.NET,data provider, ODBC driverss and OLE DB providers. To connect with individual databases this Java Database Connectivity API requires drivers for each database.

Download Link:

Use these codes to create

package login;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
 * @author HATIBU.COM
public class ConnectionClass{
    Connection con = null;  
    public static Connection java_db() throws SQLException{
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/databasename","root","paswword");
        return con;      

The java_db() is an object which will be used to call the returned connection while establishing Connection to the database, it can be named to whatever you like. Remember its is case sensitive, and you should follow java naming rules (Objects should be in lower case).

The next Post i will show how to Create login page using the connection class we created.

Any problem, suggestion Leave in the comment section.

Leave a Reply

Your email address will not be published. Required fields are marked *