Prerequisite: Creation of database and table must be done with some data in
the table.
import [Link].*; Importing the package
public class dbcon{
public static void main(String[] args) {
try {
[Link]("[Link]"); Load the Driver
Connection con =
[Link]("jdbc:mysql://localhost:3306/testdb","root",
"password"); Establishing the connection
Statement stmt = [Link](); creating the statement
ResultSet rs = [Link]("SELECT * FROM student"); Execute
Query
while([Link]()){
[Link]([Link](1)+" "+[Link](2)+" "+[Link](3));
} Process the result
[Link](); Close the connection
} catch(Exception e){
[Link](e);