Java examples for JDBC:Stored Procedure
Controlling the type value of the OUT parameter
import java.sql.CallableStatement; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Types; import java.util.Date; public class Main { public void main() { try {/*from w w w. j a v a2 s . co m*/ Connection conn = DriverManager.getConnection("...", "username", "password"); String query = "{CALL GETDATE(?,?)}"; CallableStatement callableStatement = (CallableStatement) conn.prepareCall(query); callableStatement.setInt(1, 0); callableStatement.registerOutParameter(1, Types.DATE); callableStatement.executeQuery(); Date date = callableStatement.getObject(2, Date.class); } catch (SQLException ex) { ex.printStackTrace(); } } }