There is a stored procedure that I am trying to call in an application in Java. The procedure takes two dates as input, and a cursor as output. in the database in the tables all dates are stored in the form 06.12.2018. How can I specify the dates when calling the procedure? You must specify the date of 01.11.2018 to 30.11.2018
try (Connection connection = DBConnection.getConnection()) { CallableStatement cstmt = connection.prepareCall("{call pkg_report.report_usl(?, ?, ?)}"); cstmt.setDate(1, ДАТА С); cstmt.setDate(2, ДАТА ПО); cstmt.registerOutParameter(3, OracleTypes.CURSOR); cstmt.execute(); ResultSet resultSet = (ResultSet) cstmt.getObject(3); while (resultSet.next()) { System.out.println(resultSet.getString("fam")); } } catch (Exception e) { e.printStackTrace(); }
cstmt.setDate()expects an input object of typejava.util.Date, and does not care what format it is in. - zoltjava.sql.Date, I apologize, for a long time did not look in jdbc. You can wrap your Date injava.sql.Timestamp. It should be like thiscsmt.setTimestamp(1, new Timestamp(date.getTime()))- zolt