Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: inserting java.sql.date into a oracle 8i table

Re: inserting java.sql.date into a oracle 8i table

From: C. Ferguson <c_ferguson_at_rationalconcepts.com>
Date: 2000/04/28
Message-ID: <390908B3.117B1D7E@rationalconcepts.com>#1/1

try ... email + "', to_date('" + sqlMesDate + "', 'MM/DD/RR'), '" + message...

By putting the sqlMesDate into a String the java.sql.Date did the implicit conversion to a string as java objects are want to do when you put them in as you are building the string.

So, if you were to look at the string after you built it,   System.out.println(query);
you would see you were trying to insert a string into an Oracle Date and that's why the database is complaining.

cheers,
cindy

"Adam C." wrote:

> I was wondering if any one can help me I am trying to insert a date into an
> oracle table from a servlet. This is the code I am using
> sqlMesDate = new java.sql.Date(System.currentTimeMillis());
>
> String query = "INSERT INTO MessageBoard VALUES ('" + subject + "','" + name
> + "','" + email + "'," + sqlMesDate + ",'" + message + "')" ;
>
> try
> {
> Connection dbConnection = tools.getDatabaseConnection();
> Statement statement = dbConnection.createStatement();
>
> result = statement.executeUpdate(query);
> dbConnection.close();
> }catch (SQLException sqle)
> {
> out.println(tools.getHtml("DatabaseError.htm"));
> out.println("<BR>" + sqle);
> out.close();
> }
>
> this is the error I get
> java.sql.SQLException: ORA-00932: inconsistent datatypes
Received on Fri Apr 28 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US