Advertisement
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 com.spec.service;
- import com.spec.DBUtil;
- import java.sql.CallableStatement;
- import java.sql.Connection;
- import java.sql.SQLException;
- import java.sql.Types;
- /**
- *
- * @author Admin
- */
- public class TestProcService {
- //
- public String testCall(final String value) throws Exception{
- String sql = "{? = call lower(?)}";
- try(Connection c = DBUtil.getConn(); CallableStatement cs = c.prepareCall(sql); ){
- // установка типа возвращаемого значения для функции
- cs.registerOutParameter(1, Types.VARCHAR);
- cs.setString(2, value);
- // выполнение вывозва функции
- cs.execute();
- // получение рез-та в соответсвии с типом
- String result = cs.getString(1);
- return result;
- }catch(SQLException ex){
- ex.printStackTrace();
- throw new Exception("error while testCall", ex);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement