Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: inserting java.sql.date into a oracle 8i table
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