× back
← Previous Topic

JDBC

Introduction to JDBC (Java Database Connectivity)

JDBC operations using MySQL

We will understand these operations using a program

                
import java.sql.*;
public class CRUD 
{
    public static void main(String[] args) throws Exception
    {
        Class.forName("com.mySql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/college", "root", "Root1234@");
        // now we will perform first operation which is creating a table 
        Statement st = con.createStatement();
        st.executeUpdate("create table student(rno int, name varchar(20), branch varchar(20))");// using this we are creating a table
        // closing Statement and Connection object 
        st.close();
        con.close();
    }
}