JAVA call stored procedures in oracle through callablestatem

JAVA call stored procedures in oracle through callablestatem

Postby haretu » Sat Apr 09, 2011 11:00 am

Plain old JDBC supports calling stored procedures with the CallableStatement class. That class is actually a subclass of PreparedStatement. Imagine that we have a database of books. The database has a stored procedure to set a book price.
Code: Select all
try
{
    int price = 39;
    String bookName = "harry potter";
    CallableStatement proc =
        connection.prepareCall("{ call set_book_prcie(?, ?) }");
    proc.setString(1, bookName);
    proc.setInt(2, price);
    cs.execute();
}
catch (SQLException e)
{
    // ....
}
haretu
 
Posts: 132
Joined: Sat Jan 08, 2011 9:56 pm

Return to JAVA

Who is online

Users browsing this forum: No registered users and 1 guest

cron