Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> JAVA CallableStatement

JAVA CallableStatement

From: <telzinga_at_my-deja.com>
Date: Wed, 10 Nov 1999 22:24:27 GMT
Message-ID: <80cral$j8o$1@nnrp1.deja.com>


I have been unsuccessful retrieving an OUT parameter from a stored procedure using a registerOutParameter with a CallableStatement. The stored procedure is updating the table correctly it is just not returning the OUT paramerter.

Any suggestions.



public int placeOrder(){
        java.sql.Connection conn = null;
        java.sql.Statement stmt = null;
        java.sql.ResultSet rs = null;

    	int statusMessage = 0;

	    try{

            InitialContext ctx = null;
            DataSource ds = null;
            String sql = "{call

placeorder("+this.ID+", "+this.cID+",
"+this.conID+
                         ", "+this.price+", ?)}";
            System.out.println(sql);
            ctx = new InitialContext();
            ds =
(DataSource)ctx.lookup("jdbc/db1");
            conn = ds.getConnection();
            java.sql.CallableStatement cstmt =
conn.prepareCall(sql);
            cstmt.registerOutParameter(1,
java.sql.Types.INTEGER);
            cstmt.execute();
            statusMessage = cstmt.getInt(1);
            conn.close();


}
catch(Exception e){ //Any error is grounds for rollback try{ System.out.println(e); //conn.rollback(); } catch(Exception ignored){ System.out.println("Place Order Failed"); }
}
finally { //Clean Up try{ if (conn != null) conn.close(); } catch (SQLException ignored) {}
}
return statusMessage;

  }

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Wed Nov 10 1999 - 16:24:27 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US