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.SQLException;
- import java.sql.*;
- /**
- *
- * @author Abdullah
- */
- public class OUT {
- public static void main(String[] args) throws SQLException{
- String url="jdbc:mysql://localhost:3306/demo?autoReconnect&useSSL=false";
- String user="root";
- String password="abdullah";
- String SQL=
- "{ call get_count_for_department(?,?) }"
- ;
- String Department ="HR";
- Connection connect=DriverManager.getConnection(url, user,password);
- CallableStatement CS=connect.prepareCall(SQL);
- CS.setString(1,Department);
- CS.registerOutParameter(2, Types.INTEGER);
- CS.execute();
- int Result=CS.getInt(2) ;
- System.out.println("Result="+Result);
- }
- }
Add Comment
Please, Sign In to add comment