public class GenerateSampleData { public void select() { String sql=""; Connection con = null; CallableStatement callAble=null; try{ Class.forName("com.mysql.jdbc.Driver"); String url="jdbc:mysql://localhost:3306/test"; con = DriverManager.getConnection(url, "abc", "abc"); sql="{call test2(?)}"; callAble=con.prepareCall(sql); callAble.registerOutParameter(1, Types.VARCHAR); callAble.execute(); System.out.println(callAble.getString(1)); }catch (Exception e) { // TODO: handle exception e.printStackTrace(); }finally{ try { callAble.close(); con.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }