Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Databases > Oracle Date dat...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 3596 of 3876
Post > Topic >>

Oracle Date data type insert and format

by "teser3@[EMAIL PROTECTED] " <teser3@[EMAIL PROTECTED] > Nov 19, 2007 at 04:24 PM

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?
 




 3 Posts in Topic:
Oracle Date data type insert and format
"teser3@[EMAIL PROTE  2007-11-19 16:24:16 
Re: Oracle Date data type insert and format
"teser3@[EMAIL PROTE  2007-11-19 17:59:07 
Re: Oracle Date data type insert and format
=?ISO-8859-1?Q?Arne_Vajh=  2007-11-19 21:35:39 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 23:25:53 CST 2008.