Lalit Ingale wrote:
>
> Hi,
>
> U r using a simple insert sql so why dont u use
> Statement instead of PreparedStatement.
> bcos PreparedStatement is used for stored procs and
> not simple statements it may be hanging.

This is not correct. Using a PreparedStatement for a simple insert will not
cause the program to hang. Prepared Statements can be used for stored
procedures, but that is not their sole purpose. In my mind it is not even their
primary purpose. PreparedStatements are used whenever you have a statement where
the only thing that changes is the host variables.

> >From: Manoj Agrawal <[EMAIL PROTECTED]>
> >      I am trying to insert a date into Oracle data base and the
> >application hangs on the insert. Here is the code
> >
> >       PreparedStatement put_into_table = con.prepareStatement(
> >
> >       "insert into salereport values ( ? ,?)");
> >       SimpleDateFormat formatter  = new SimpleDateFormat ("dd-MMM-yyyy");
> >       java.util.Date qryDate = formatter.parse("02-MAR-2000");
> >      long timeinmilli =  qryDate.getTime();
> >      java.sql.Date sqlDate = new java.sql.Date(timeinmilli);
> >
> >      put_into_table.setDate(1, sqlDate);
> >      put_into_table.setString(2, lineitemtype);
> >
> >      int row_inserted = put_into_table.executeUpdate();
> >
> >
> >      Does any body have any clue what is wrong with this code ?

Some things to try or check
- put a try-catch block around the code to see if an exception is thrown
- since you use positional syntax, is the first field in the table a date?
- is the second field a string?

K Mukhar

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to