-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBjdbcdemo.java
More file actions
23 lines (19 loc) · 789 Bytes
/
Bjdbcdemo.java
File metadata and controls
23 lines (19 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.sql.*;
public class Bjdbcdemo {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3308/Bjdbc","root","");
Statement s = con.createStatement();
// using here CallableStatement object to call a stored procedure declared in phpmyadmin with name "GetData"
CallableStatement cs = con.prepareCall("{call GetData()}");
cs.execute();
// Creation of resultset object and populate with data
ResultSet rs =cs.getResultSet();
// printing the values from the resultset
while(rs.next())
{
System.out.println(rs.getInt(1));
System.out.println(rs.getString(2));
}
}
}