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?

what do you mean "but you couldn't format it"?
A Date's a Date. There's no need to format anything when working with a Date internally.
Only when presenting it for output may you want to perform formatting.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.