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(); } 
  • Have you tried to run it? cstmt.setDate() expects an input object of type java.util.Date , and does not care what format it is in. - zolt
  • I wrote so SimpleDateFormat formatDate2 = new SimpleDateFormat ("dd.M.YYYY"); Date parsedDate2 = formatDate2.parse ("12/31/2018"); gives the error Cannot resolve method 'setDate (int, java.util.Date)' - Kolhoznik
  • I think java.sql.Date is needed there - Kolhoznik
  • Yes, exactly, java.sql.Date , I apologize, for a long time did not look in jdbc. You can wrap your Date in java.sql.Timestamp . It should be like this csmt.setTimestamp(1, new Timestamp(date.getTime())) - zolt
  • Thank you, but it's still not clear how to specify the date I need. I want to specify the date 01/11/2018 I do the following: SimpleDateFormat formatDate1 = new SimpleDateFormat ("dd.M.YYYY"); Date parsedDate1 = formatDate1.parse ("11/01/2018"); but in the end the date turns out to be 01/01/2018 - Kolhoznik

0