Steps to Connect with Database 🔥🔥 | Explained in Detail (Java Database Connectivity) - JDBC #3
154.2 هزار بار بازدید -
5 سال پیش
-
What are the steps that
What are the steps that are required to connect with the database in JDBC.
I have explained in brief what are the steps to follow to connect with database and perform operations with the database.
Steps to Connect with Database , explained in Detail (Java Database Connectivity) - JDBC #3
how to connect java program with database
1) load the driver:
Class.forName("com.mysql.jdbc.Driver")//
2)Create a Connection:
Connection con=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/dbname","root","root");
3)Create query, Statement , PreparedStatement , CallableStatement
eg
String q="select * from students";
Statement stmt=con.createStatement();
ResultSet set=stmt.executeQuery(q);
4)Process the data :
while(set.next())
{
int id=set.getInt("studentID");
String name=set.getString("studentName");
System.out.println(id);
System.out.println(name);
}
5) Close the connection:
con.close();
I have explained in brief what are the steps to follow to connect with database and perform operations with the database.
Steps to Connect with Database , explained in Detail (Java Database Connectivity) - JDBC #3
how to connect java program with database
1) load the driver:
Class.forName("com.mysql.jdbc.Driver")//
2)Create a Connection:
Connection con=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/dbname","root","root");
3)Create query, Statement , PreparedStatement , CallableStatement
eg
String q="select * from students";
Statement stmt=con.createStatement();
ResultSet set=stmt.executeQuery(q);
4)Process the data :
while(set.next())
{
int id=set.getInt("studentID");
String name=set.getString("studentName");
System.out.println(id);
System.out.println(name);
}
5) Close the connection:
con.close();
5 سال پیش
در تاریخ 1398/04/23 منتشر شده
است.
154,286
بـار بازدید شده