Abdullah047

INOUT_SQL

Sep 2nd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package sqltest;
  7.  
  8. import java.sql.DriverManager;
  9. import java.sql.*;
  10. /**
  11.  *
  12.  * @author Abdullah
  13.  */
  14. public class INOUT {
  15.     public static void main(String[] ags) throws SQLException{
  16.         String url="jdbc:mysql://localhost/demo?autoReconnect&useSSL=false";
  17.         String user="root";
  18.         String password="abdullah";
  19.         String SQL=
  20.     " { call greet_the_department (?)  }"
  21.                 ;
  22.         String Department="HR";
  23.    Connection connect=DriverManager.getConnection(url,user,password );
  24.     CallableStatement CS=connect.prepareCall(SQL);
  25.  //   CS.registerOutParameter(1, Types.VARCHAR);
  26.     CS.setString(1,Department);
  27.    
  28.     CS.execute();
  29.    
  30. String set=CS.getString(1);
  31. System.out.println(  set );
  32.    
  33.     }
  34. }
Add Comment
Please, Sign In to add comment