(AJP) Chapter 2
(AJP) Chapter 2
(AJP) Chapter 2
INFORMATICS
DEPARTMENT OF SOFTWARE
ENGINEERING
BY SAMSON R.
Chapter five
jdbc
Contents
Introduction.
JDBC Architecture
B Methods
Methods
1. next(): Indicates next row.
2. getRow(): Returns row number.
1. Register a driver
2. Specify JDBC URL
6. Process Results
7. Close the connection
Cont..
Add Library
RC on Database
New connection
Select MySQL (connector /J Driver) from the Drop down list and Next
Give the database name, username and password and Test connection
Finish
p l e
a
x cm es
E ample
od
S
Inserting Data
import java.sql.*;
public class InsertData
{
public static void main(String args[])
{ Connection conn = null;
try
{ String userName = "admin";
String password = "1234";
String url =
"jdbc:mysql://localhost:3306/student";
Class.forName("com.mysql.jdbc.Driver");
conn =
DriverManager.getConnection(url,userName,password);
Statement stmt=conn.createStatement();
Cont.…
Connection con;
Statement st;
ResultSet res;
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/FRIDAY","roo
t","");