Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package sqltest;
- import java.sql.CallableStatement;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- /**
- *
- * @author Abdullah
- */
- public class Stored_procedure_ResultSet {
- public static void main(String[] ags) throws SQLException{
- String URL="jdbc:mysql://localhost:3306/demo?autoReconnnect&useSSL=false";
- String user="root";
- String password="abdullah";
- String SQL=
- "{ call get_employees_for_department(?) } "
- ;
- String Department="Legal";
- Connection connect=DriverManager.getConnection(URL,user,password);
- CallableStatement CS=connect.prepareCall(SQL);
- CS.setString(1, Department);
- CS.execute();
- ResultSet result=CS.getResultSet();
- Display(result);
- }
- public static void Display(ResultSet result) throws SQLException{
- while(result.next()){
- System.out.println(result.getString(1)+"\t"+result.getString(2)+"\t"+result.getString(3)+"\t"
- +result.getString(4)+"\t"+result.getString(5)+"\t"+result.getString(6)+"\t"
- +result.getString(7)+"\t"
- ) ;
- }
- }
- }
Add Comment
Please, Sign In to add comment