my dog learned polymorphism
The moose likes JDBC and Relational Databases and the fly likes inserting date  to oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "inserting date  to oracle" Watch "inserting date  to oracle" New topic

inserting date to oracle

Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
I got two questions.

1.Latest version of JDBC API?
2.I am working on a GUI based application that involves interaction with database. I had used PreparedStatement for executing queries. I want to sent the date which I am getting as an input from the user to the database. I used the following statement
stmt.setDate(4,txtyear.getText()); and I am getting compilation error. My database is Oracle and I had set that particular column which receives input from the above setString() method with Date datatype. Some one please help me.

Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

1. That's not a question. Do you mean "What is the latest version of the JDBC API?". Or "Where is the latest verson of the JDBC API?".
2. Re-read the JavaDocs for the PreparedStatement setDate methods. There isn't one which takes a String.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
May i know what compilation error you are getting in.

Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32628

1) JDBC 3.0 came out with Java 1.4. I don't recall the version number with Java 1.5. It does have some new JDBC features, so the version number has changed.
2) setDate() takes a Date object as the second parameter. getText() returns a String. You can use the SimpleDateFormat class to turn that String into a Date.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: inserting date to oracle
It's not a secret anymore!