Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.48 KB | None | 0 0
  1. import java.sql.CallableStatement;
  2. import java.sql.Connection;
  3. import java.sql.DriverManager;
  4. import java.sql.ResultSet;
  5. import java.sql.Types;
  6. import java.sql.SQLException;
  7. import java.sql.Statement;
  8. import java.sql.PreparedStatement;
  9. import java.sql.CallableStatement;
  10. import java.sql.Struct;
  11. import java.sql.Array;
  12.  
  13. public class testJava {
  14.  
  15.   public static void main(String[] args) throws Exception {
  16.  
  17.  
  18.     Connection con = null;
  19.     Statement st = null;
  20.     ResultSet rs = null;
  21.  
  22.     Integer val=5;
  23.     String url = "jdbc:edb://192.168.59.103:22222/richyen_test";
  24.     String user = "enterprisedb";
  25.     String password = "o1234";
  26.  
  27.     try {
  28.       con = DriverManager.getConnection(url, user, password);
  29.  
  30.       Integer in;
  31.       String sql = "{call public.get_user_state_from_sat_id(?)}";
  32.  
  33.       CallableStatement cs = con.prepareCall(sql);
  34.             for ( int i = 0; i < 100; i++ ) {
  35.                             cs.setObject(1, 1112);
  36.                             cs.execute();
  37.                             ResultSet res = cs.getResultSet();
  38.                             while ( res.next() ){
  39.                               in = res.getInt(1);
  40.                               System.out.println(in);
  41.                             }
  42.             }
  43.     } catch (SQLException ex)
  44.     {
  45.       System.out.println(ex);
  46.     }
  47.  
  48.     finally {
  49.       try {
  50.  
  51.         if (con != null)
  52.  
  53.         {
  54.           con.close();
  55.         }
  56.  
  57.       } catch (SQLException ex)
  58.       {
  59.         System.out.println(ex);
  60.       }
  61.     }
  62.   }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement