Sample stored procedure call using JDBC:Call stored procedure to change/set a value in the database
//set birthday - supply professor nametry{ String professor= "dylan thomas"; CallableStatement proc = connection.prepareCall("{ call set_birth_date(?, ?) }"); proc.setString(1, professor); proc.setString(2, '1950-01-01'); cs.execute();}catch (SQLException e){ // ....}Stored procedures can also return result/data to the caller: like//return birth dayconnection.setAutoCommit(false);CallableStatement proc = connection.prepareCall("{ ? = call birthday_when(?) }");proc.registerOutParameter(1, Types.Timestamp);proc.setString(2, professorName);cs.execute();Timestamp age = proc.getString(2);Stored procedures can also return complex data like resultsets. JDBC drivers from oracle, Sql Server, PostgreSQL support this.
From: http://sitestree.com/?p=4839
Categories:Java Short Notes
Tags:
Post Data:2010-07-30 07:32:42
Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada