Oracle Date data type insert and format



I have a Date insert that is formatted into an Oracle 9i database and
it works.
But I had to make the Date variable a varchar2 in Oracle to get it to
work:


......
java.sql.Timestamp myd = new java.sql.Timestamp(new
java.util.Date().getTime());
String sub_date = new SimpleDateFormat("mm/dd/yy , h:mm
a").format(myd);
String query = "insert into dept(location, sub_date) values(?, ?)";
PreparedStatement pstmt =
conn.prepareStatement(query);
pstmt.setString(1, "Jersey");
pstmt.setString(2, sub_date);
pstmt.executeUpdate();
.......



I also tried pstmt.setDate(2, sub_date) with a Date data type in
Oracle and I could get the date to insert but couldnt format it.

Please advise how I can get the Oracle Date datatype to work where I
can also format it?
.



Relevant Pages

  • Re: Generic DBI question about backups
    ... our only Oracle database will be gone by the time one is selected. ... Which was the reason for the need of a database independent solution. ... I would recommend using a consistent text backup format. ... newlines, pipe symbols and escapes (eg, backslash-backslash for a single ...
    (perl.dbi.users)
  • Re: Date and time conversion
    ... Insted of using template classes for manipulating dates I sugest using ... standard libc routines for manipulating dates form database. ... it with Oracle and is quite simple. ... time manipulation routines and format). ...
    (comp.lang.cpp)
  • Re: Date and time conversion
    ... Insted of using template classes for manipulating dates I sugest using ... standard libc routines for manipulating dates form database. ... it with Oracle and is quite simple. ... time manipulation routines and format). ...
    (comp.os.linux.development.apps)
  • Re: Date Formats
    ... tables of SQL Server. ... I had problem in exporting these fields into Oracle. ... > I presume that the problem is that Oracle doesn't interpret the datetime values from SQL server ... > a format, hence trying to enforce a format for that datatype is meaningless. ...
    (microsoft.public.sqlserver.programming)
  • Re: No one could logon to productio database for a while
    ... Puget Sound Oracle Users Group ... code for script is quite simple, it does a v$sql to find all sql ... The script ask for the hash value of the SQL statement. ... col "SLAVE SQL" format A95 WORD_WRAP ...
    (comp.databases.oracle.server)