| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package UIJ.UIJ03;
- import java.sql.CallableStatement;
- import java.sql.Connection;
- import java.sql.SQLException;
- import java.sql.Types;
- public class SqlUtil {
- public static void execProduce(Connection conn,String produceName,String []inparams,String []outparams) throws SQLException{
- if(conn == null){
- return;
- }
- CallableStatement cstmt = null;
-
- try{
- cstmt = conn.prepareCall(produceName);
- int index = 1;
- for(int i = 0;i < inparams.length;i++){
- cstmt.setString(index, inparams[i]);
- index++;
- }
- for(int i = 0;i < outparams.length;i++){
- cstmt.registerOutParameter(index, Types.VARCHAR);
- index++;
- }
-
- cstmt.execute();
-
- for(int i = 0;i < outparams.length;i++){
- outparams[i] = cstmt.getString(i+1);
- }
- }
- catch(SQLException ex){
- System.out.println(ex.getMessage());
- throw ex;
- }
- finally{
- cstmt.close();
- conn.close();
- }
- }
- }
|