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 7992141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:29:02+00:00 2026-06-04T13:29:02+00:00

I am trying to retrieve data from JTable and then use it to update

  • 0

I am trying to retrieve data from JTable and then use it to update an sql table saved in database. However, java gives me this error,

ORA-01861: literal does not match format string

I have tried to include different strings and it worked, but for this case, it does not.
Can someone please help?
Here’s my code,

for(int i=0; i<size; i++)
            {
                Object fname= searchResultTable.getModel().getValueAt(i,0);
                Object lname= searchResultTable.getModel().getValueAt(i,1);
                Object minit= searchResultTable.getModel().getValueAt(i,2);
                Object SSN  = searchResultTable.getModel().getValueAt(i,3);
                Object birthDate=searchResultTable.getModel().getValueAt(i,4);
                Object address = searchResultTable.getModel().getValueAt(i,5);
                Object sex = searchResultTable.getModel().getValueAt(i,6);
                Object salary = searchResultTable.getModel().getValueAt(i,7);
                Object superSSN = searchResultTable.getModel().getValueAt(i,8);
                Object dno = searchResultTable.getModel().getValueAt(i,9);




               // Statement S = conn.createStatement();
               // String query ="UPDATE EMPLOYEE SET fname='"+fname+"', lname='"+lname+"', minit='"+minit+"', ssn='"+SSN+"', bdate='"+birthDate+"', address='"+address+"', sex='"+sex+"', salary='"+salary+"', superssn='"+superSSN+"', dno='"+dno+"' WHERE ssn='"+ssn.get(i)+"' ";
               // query="UPDATE EMPLOYEE set fname='Ray',lname='King' where fname='Ray' and lname='King' ";

                 String query ="UPDATE EMPLOYEE SET fname=?, lname=?, minit=?, ssn=?, bdate=?, address=?, sex=?, salary=?, superssn=?, dno=? WHERE ssn=?";

                try{
                PreparedStatement S = conn.prepareStatement(query);
                S.clearParameters();
                S.setString(1,fname.toString());
                S.setString(2, lname.toString());
                S.setString(3, minit.toString());
                S.setString(4, SSN.toString());
                S.setString(5, birthDate.toString());
                S.setString(6,address.toString());
                S.setString(7, sex.toString());
                S.setString(8, salary.toString());
                S.setString(9, superSSN.toString());
                S.setString(10,dno.toString());
                S.setString(11, ssn.get(i));

                System.out.println(fname+", "+lname+","+salary);

                int count= S.executeUpdate();
                JOptionPane.showMessageDialog(this, "Employee Table Was Updated Successfully");
                }catch(SQLException sqle){System.out.println(sqle.getMessage());}



            }
        }
  • 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-04T13:29:03+00:00Added an answer on June 4, 2026 at 1:29 pm

    @dasblinkenlight, your way doesn’t compile.

    here’ a method that converts java format to sql format, it works for sure.

     public String dateToSQLFromat(String javaString)
        {
    
            String day="", month="", year="";
    
            int dash=0;
            for(int i=0; i<javaString.length(); i++)
            {
    
                if(javaString.charAt(i)=='-')
                {
                    dash++;
                    continue;
                }
    
                if(dash==0)
                {
                year= year+javaString.charAt(i);
    
                }
                else if(dash==1)
                month= month+javaString.charAt(i);
                else
                {
    
                    if(javaString.charAt(i)==' ')
                        break;
    
                   day= day+javaString.charAt(i);  
                }
            }
    
    
            int myMonth= Integer.parseInt(month);
    
            switch(myMonth)
            {
                case 1: month="JAN"; break;
                case 2: month="FEB";break;
                case 3: month="MAR"; break;
                case 4: month="APR"; break;
                case 5: month= "MAY"; break;
                case 6: month= "JUN"; break;
                case 7: month= "JUL"; break;
                case 8: month="AUG"; break;
                case 9: month="SEP"; break;
                case 10: month="OCT"; break;
                case 11: month="NOV"; break;
                case 12: month="DEC"; break;
                default: System.out.println("Invalid month!"); break;
            }
    
    
            return day+"-"+month+"-"+year;
    
    
    
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to retrieve data using linq from a database. I would like to use
i am trying to retrieve data from a database and display then on a
Iam trying to retrieve data from mysql database into stylesheet.php but it is not
I'm trying to retrieve hierarchical data from a table but am failing to do
I'm trying to retrieve record data from an MS-Access database and store it into
I am trying to retrieve specific data from my MySQL database by passing the
I'm trying to use Python 2.7 regex's to retrieve data from sample web pages
I am trying to retrieve and use the raw data from RSS feeds. For
I am trying to re-retrieve data from my database whenever the user clicks on
I am trying to retrieve data from mysql then display it on android listview.

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.