Advanced JDBC Techniques

1. Stored Procedures: CallableStatement

Synatax for a procedure that doesn't return a result is {call procedure_name(.., >>)}, Synatax that return a result value is {?= call procedure_name(.., ..)}. Using like below:

CallableStatment cstmt = con.prepareCall("{call p_name(.., ..)}"); // like PreparedStatement

cstmt.registerOutParameter(col_num, java.sql.Types.FLOAT);  //declear that the type of the value returned if FLOAT

cstmt.setInt(col_num, value);

cstmt.execute();

cstmt.getFloat(col_num);

2.Binaries and Books: ResultSet.getAsciiStream() handles large text strings, getBinaryStream() works for large binary objects.

When reading from InputStream(from getAsciiStream()), the servlet doesn't get the value of any other columns in the result set, because  calling any other getXxx() metod of ResultSet closes the InputStream.

你可能感兴趣的:(sql,jdbc,servlet)