SetDate « Date « Java Database Q&A

Home
Java Database Q&A
1.Blob
2.cassandra
3.column
4.Connection
5.Cursor
6.dao
7.Data Type
8.Database
9.Database Product
10.DataSource
11.Date
12.db2
13.derby
14.Development
15.Driver
16.Exception
17.file
18.hadoop
19.hbase
20.hsqldb
21.ibatis
22.JDBC
23.memcached
24.mongodb
25.MS Access
26.mysql
27.ODBC
28.Operation
29.oracle
30.postgresql
31.Record
32.result
33.Resultset
34.Schema
35.SQL
36.sqlite
37.SQLserver
38.Statement
39.stored procedure
40.sybase
41.Table
42.Transaction
43.Trigger
Java Database Q&A » Date » SetDate 

1. SetDate with Statement?    stackoverflow.com

With PreparedStatement, you just call SetDate and be done with it. How do you pass in a Date with a regular Statement?

2. JDBC Prepared Statement . setDate(....) doesn't save the time, just the date.. How can I save the time as well?    stackoverflow.com

I have the following Query :

INSERT INTO users (user_id, date_created) VALUES (?,?)
I have the following prepared statement
PreparedStatement insertUser = dbConnection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);

insertUser.setInt(1, 7);
java.util.Date now = new java.util.Date(System.currentTimeMillis());
insertUser.setDate(2, new java.sql.Date((new Date(System.currentTimeMillis())).getTime()));
insertUser.executeUpdate();
If i check ...

4. doubts in setDate(i,date,cal) API of preparedStatement    coderanch.com

What error are you getting ? Check out my code below /** * Author Ujjwal B Soni * Code Added : 29th December 2008 * Last Modified 31st July 2009 */ import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; public class DemoPreparedStatementSetDate { public static java.sql.Date getCurrentJavaSqlDate() { java.util.Date today = new java.util.Date(); return new java.sql.Date(today.getTime()); } public static Connection getConnection() throws Exception ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.