278d8dcb940da45af91660866461f6262cbe611b.svn-base 903 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package UIJ.UIJ03;
  2. import java.sql.CallableStatement;
  3. import java.sql.Connection;
  4. import java.sql.SQLException;
  5. import java.sql.Types;
  6. public class SqlUtil {
  7. public static void execProduce(Connection conn,String produceName,String []inparams,String []outparams) throws SQLException{
  8. if(conn == null){
  9. return;
  10. }
  11. CallableStatement cstmt = null;
  12. try{
  13. cstmt = conn.prepareCall(produceName);
  14. int index = 1;
  15. for(int i = 0;i < inparams.length;i++){
  16. cstmt.setString(index, inparams[i]);
  17. index++;
  18. }
  19. for(int i = 0;i < outparams.length;i++){
  20. cstmt.registerOutParameter(index, Types.VARCHAR);
  21. index++;
  22. }
  23. cstmt.execute();
  24. for(int i = 0;i < outparams.length;i++){
  25. outparams[i] = cstmt.getString(i+1);
  26. }
  27. }
  28. catch(SQLException ex){
  29. System.out.println(ex.getMessage());
  30. throw ex;
  31. }
  32. finally{
  33. cstmt.close();
  34. conn.close();
  35. }
  36. }
  37. }