Description:
Java JDBC is a java API to connect and execute query with the database. JDBC API uses jdbc drivers to connect with the database.
Learn through my videos:

Program:
package com.telusko.jdbcdemo;
import java.sql.*;
public class DemoJDBC {
	
	public static void main(String[] args)
	{
		
		try {
			 String Query="Select * from {tablename} where {condition}";
			//2nd step:
			Class.forName("com.mysql.jdbc.Driver");
			//3rd step:
			Connection con=DriverManager.getConnection("jdbc:mysql://localhost/{Database name}","{username}", "{password}");
			//4th step:
			Statement st=con.createStatement();
			//5th step:
			ResultSet rs=st.executeQuery(Query);
			//6th step
			rs.next();
			String sname=rs.getString(2);
			System.out.println(sname);
			//7th step
			con.close();
			
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
}

Output:
Navin 
Logic:
The above codes are basic step for making connection with the database we are doing it with mysql database  .In the connection string we need to pass the username and password of mysql .The statement object allow you to The term "result set" refers to the row and column data contained in a ResultSet object.send sql querry . A ResultSet object maintains a cursor that points to the current row in the result set. The query fetches the student name according to the rollno.