-
Notifications
You must be signed in to change notification settings - Fork 0
/
qb383.java
33 lines (26 loc) · 1.02 KB
/
qb383.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.*;
import java.sql.*;
class QB383 {
public static void main(String[] args) throws Exception {
String drivername = "com.mysql.cj.jdbc.Driver";
Class.forName(drivername);
String dburl = "jdbc:mysql://localhost:3306/ishan_database";
String dbname = "root";
String dbpass = "";
Connection con = DriverManager.getConnection(dburl, dbname, dbpass);
if (con != null) {
System.out.println("Connection Succesfull");
} else {
System.out.println("Connection Failed !!");
}
String sql = "{call getEmployees()}";
CallableStatement cst = con.prepareCall(sql);
ResultSet rs = cst.executeQuery();
while (rs.next()) {
System.out.println("Name: " + rs.getString("emp_name"));
System.out.println("Age: " + rs.getInt("emp_age"));
System.out.println("Mobile: " + rs.getLong("emp_mob"));
System.out.println("Salary: " + rs.getFloat("emp_salary"));
}
}
}