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

  • Home
  • SEARCH
  • 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 9044197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:55:29+00:00 2026-06-16T10:55:29+00:00

I am trying to insert few values into oracle table (oracle 10g) using JSP.

  • 0

I am trying to insert few values into oracle table (oracle 10g) using JSP. I have been encountering ORA-01861 error… Can some one please help me out.

int eid = Integer.parseInt(request.getParameter("srno"));
String enm = "";
int exit_tp = Integer.parseInt(request.getParameter("applntype"));
int ecadre = 0;
String ecdr = "";
String epost = "";
String edob = "";
String eappt_da = "";
String ecadre_date = "";
String edor = "";
String esubmitted_by = "";
String esubmitted_ip = "";
String ezn = "";
String ezone = "";
String edivision = "";
String ebranch = "";

String tmp = "select ep.name,ep.cadre,cd.descpn,epv.post,ep.dob,ef.appt_da,ep.cadre_date,add_months(ep.dob-1,720),z.short,ep.zone,ep.division,ep.branch " +
        "from empfile ef,emp_prov ep,v$emp_prov epv,cadre cd,zone z " +
        "where ep.srno=epv.srno(+) " +
        "and ef.srno=ep.srno(+) " +
        "and ep.cadre=cd.code(+) " +
        "and ep.zone=z.zn(+) " +
        "and ep.srno=" + eid;

PreparedStatement stmt = conn.prepareStatement(tmp);

ResultSet rset = stmt.executeQuery();

if (rset.next()) {
    enm = rset.getString(1);
    ecadre = rset.getInt(2);
    ecdr = rset.getString(3);
    epost = rset.getString(4);
    edob = rset.getString(5);
    eappt_da = rset.getString(6);
    ecadre_date = rset.getString(7);
    edor = rset.getString(8);
    ezn = rset.getString(9);
    ezone = rset.getString(10);
    edivision = rset.getString(11);
    ebranch = rset.getString(12);
}
rset.close();
stmt.close();

String tmp1 = "insert into online_exit(srno,name,exitcode,cadre,post,dob,appt_da,cadre_date,dor,submit_date,submit_stt,zone,division,branch) " +
        "values (?,?,?,?,?,to_date(?,'DD/MM/YYYY'),to_date(?,'DD/MM/YYYY'),to_date(?,'DD/MM/YYYY'),to_date(?,'DD/MM/YYYY'),SYSDATE,2,?,?,?)";

PreparedStatement pstmt = conn.prepareStatement(tmp1);

pstmt.setInt(1, eid);
pstmt.setString(2, enm);
pstmt.setInt(3, exit_tp);
pstmt.setInt(4, ecadre);
pstmt.setString(5, epost);
pstmt.setString(6, edob);
pstmt.setString(7, eappt_da);
pstmt.setString(8, ecadre_date);
pstmt.setString(9, edor);
pstmt.setString(10, ezone);
pstmt.setString(11, edivision);
pstmt.setString(12, ebranch);

pstmt.executeUpdate();

pstmt.close();
conn.close();

The description of the table is as follows

Name                                      Null?    Type
 ----------------------------------------- -------- ------------
 SRNO                                      NOT NULL NUMBER(6)
 NAME                                               VARCHAR2(50)
 EXITCODE                                           NUMBER(2)
 CADRE                                              NUMBER(2)
 POST                                               VARCHAR2(30)
 DOB                                                DATE
 APPT_DA                                         DATE
 CADRE_DATE                                         DATE
 CONF_STT                                           VARCHAR2(3)
 DOR                                                DATE
 VIG_DIS_STT                                        VARCHAR2(50)
 APPLN_DA                                           DATE
 APPLN_ACK_DA                                       DATE
 REC_CO_DA                                          DATE
 PREF_EXIT_DA                                       DATE
 NOTICE_PER_EXP_DA                                  DATE
 REASON                                             VARCHAR2(50)
 PENSION_OPT                                        VARCHAR2(2)
 REVERSN                                            VARCHAR2(2)
 COMP_AUTH                                          NUMBER
 EXIT_DATE                                          DATE
 SUBITTED_BY                                        NUMBER(6)
 SUBMIT_DATE                                        DATE
 SUBMITTED_IP                                       VARCHAR2(15)
 VALIDATED_BY                                       NUMBER(6)
 VALIDATED_ON                                       DATE
 VALIDATE_IP                                        VARCHAR2(15)
 SUBMIT_STT                                         NUMBER(2)
 ZONE                                               VARCHAR2(2)
 DIVISION                                           VARCHAR2(3)
 BRANCH                                             VARCHAR2(4)
  • 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-16T10:55:30+00:00Added an answer on June 16, 2026 at 10:55 am

    Use ResultSet#getDate() method to return java.sql.Date and call the PreparedStatement#setDate() method to assign java.sql.Date to the parameter.

    java.sql.Date edob;
    ...
    if (rset.next()) {
      ..... 
      edob = rset.getDate(5);
      ....
    }
    ....
    String tmp1 = "insert into online_exit(srno,name,exitcode,cadre,post,dob,appt_da,cadre_date,dor,"
                 +"submit_date,submit_stt,zone,division,branch) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
    
    PreparedStatement pstmt = conn.prepareStatement(tmp1);
    
    .....
    pstmt.setDate(6, edob);
    .....
    

    NOTE: If you have string date then use SimpleDateFormat methods to parse the string date.

    EDIT:

    when i tried to initialize java.sql.Date edob = new java.sql.Date(), I am getting “The constructor Date() is undefined” error

    You’ve to instantiate the java.sql.Date by passing millis to its constructor:

    java.sql.Date edob=new java.sql.Date(new java.util.Date().getTime());
    //Or use java.sql.Date.valueOf() method
    java.sql.Date date=java.sql.Date.valueOf("2012-12-31");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to insert 315K Gif files into an Oracle 10g database. Everytime I get
im trying to insert an array values into the file using foreach.. and if
im trying to insert this query with mysql_query INSERT INTO um_group_rights (`um_group_id`,`cms_usecase_id`,`um_right_id`) VALUES (2,1,1)
I am trying to insert over 70,000 rows into a javascript database (using Chrome
I'm using ASP.NET/VB and I'm trying to insert a date and time into an
I have been trying to work out a few reports based off some log
I have a form with a few rows that I am trying to insert
Am trying to insert XML into XML Column.. getting following error: . Msg 6819,
I'm trying to insert into an array at a certain point: $hi = test;
I'm trying to insert a new meta tag within the Head, I'm using a

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.