Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8024507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:53:21+00:00 2026-06-04T22:53:21+00:00

I want to pass sys date to my procedure. Below is my code snippet

  • 0

I want to pass sys date to my procedure.
Below is my code snippet

 DateFormat dateFormat = new SimpleDateFormat("mm/dd/yyyy");
                                           Date date = new Date();
String insertquery="{ call sp_process_job (?,?,?) }";

                    cs = con.prepareCall(insertquery.toString());
                    cs.setString(1,id);
                    cs.setString(2,host);
                    cs.setDate(19,(java.sql.Date) date);
                                          cs.execute();
                          con.commit();

My stored Procedure

create procedure sp_process_job (@request_id varchar(25),@host varchar(20),@created_on varchar(25)) as

begin

set dateformat mdy
SELECT CAST(@created_on as datetime)
insert into t_job_details(request_id,host,created_on,run_date) 
                values(@request_id,@host,@created_on)

end

getting this error

java.util.Date cannot be cast to java.sql.Date.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:53:22+00:00Added an answer on June 4, 2026 at 10:53 pm

    You can’t cast java.util.Date to java.sql.Date because the second is a subclass of the first.

    You could do:

    cs.setDate(19, new java.sql.Date(date.getTime()));
    

    And remember that java.sql.Date will have everything but the month, day, and year zeroed out. As the java.sql.Date javadoc says:

    To conform with the definition of SQL DATE, the millisecond values wrapped by a java.sql.Date instance must be ‘normalized’ by setting the hours, minutes, seconds, and milliseconds to zero in the particular time zone with which the instance is associated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to alter the procedure sys.sp_executesql in the master database (in the enhanced
I'm new to JasperReports . I want to pass ArrayList to subreport of subreport.
I want pass a class-instace to a method of an other and be sure
i want to pass the value of a datetimepicker to my Codebehind(C#) and save
I want to pass the id from one action to the next action, but
I want to pass data from client side to server-side. I am using jQuery
I want to pass an IEnumerable collection from view to controller using JQuery from
I want to pass value of i as a parameter for autosuggest. My intention
I want to pass id from view to controller. I know how to pass
I want to pass a custom object from one Activity to another, here is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.