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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:38:27+00:00 2026-05-31T00:38:27+00:00

So what I want to do is set a custom date along with the

  • 0

So what I want to do is set a custom date along with the current time into the DATE type in the Oracle database.
I get the string from textField in the form of mm/dd/yyyy

 String tdate = textDate.getText().trim();

To simplify the details lets just insert the DATE into a small table.

 Calendar calendar = Calendar.getInstance();                                
 int hour = calendar.get(Calendar.HOUR);
 int minute = calendar.get(Calendar.MINUTE);
 int second = calendar.get(Calendar.SECOND);
 String current_time = hour+":"+minute+":"+second;

now we have tdate as the string of date and current_time as the current time.

to put into a database with table defined as :

create table transaction(
              tranaction_num integer,
              time_of_transaction DATE);

now in jdbc

PreparedStatement pStmt = Conn.prepareStatement("insert into transaction values(?,?));
pStmt.setString(1, "1");
pStmt.setString(2, "to_date( '"+tdate+" "+current_time+"','mm/dd/yyyy hh24:mi:ss')");
pStmt.executeUpdate();

This gives me an error as below

 ORA-01858: a non-numeric character was found where a numeric was expected

I know I am doing something wrong but I have tried so many things to get this working. I don’t mind getting the current time some other way as long as it is working

Any help would be appreciated

  • 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-05-31T00:38:29+00:00Added an answer on May 31, 2026 at 12:38 am

    If you want to pass a string, you probably want something like

    String sqlStmt = "insert into transaction values(?,to_date(?,'mm/dd/yyyy hh24:mi:ss'))"
    PreparedStatement pStmt = Conn.prepareStatement(sqlStmt);
    pStmt.setString(1, "1");
    pStmt.setString(2, tdate+" "+current_time);
    pStmt.executeUpdate();
    

    From a good coding standpoint, however, you would be much better served doing a setInt for the first parameter and a setDate on the second parameter rather than passing everything as strings.

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

Sidebar

Related Questions

I want to create a custom set that will automatically convert objects into a
i want maven to download custom jar files from an ftp how to set
I want a nice way to get the current unix timestamp from a java
I have a custom control that print the current date into the page. The
Is there possibility to set a custom date in DatePicker? I want to set
I created a custom EditorPart, and I want to set the Zone and ZoneIndex
I want to set custom Post-Login Destinations based on user ROLES in my application.
In Contacts I have set up a Date field with a custom label (when
Hi I want to set min date in my jQuery datepicker to (1999-10-25). So
I want to set up an ASP.NET custom control such that it has 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.