PreparedStatement

hi ,

can anyone suggest me how to use the

setDate method from Preparedstatement.....my req is

PreparedStatement updateSales = connection.prepareStatement("Insert into emp1 (empno,ename,dob) values (?,?,?)");

int n =7;

updateSales.setInt(1,n);

updateSales.setString(2, "TEST");

Date d = 18/12/2000 ;

updateSales.setDate(2,d);

updateSales.executeUpdate();

How to use the updateSales.setDate( ) .....

Pls let me know

ta

Sunny

[508 byte] By [GloomyProgrammera] at [2007-11-27 5:22:34]
# 1

1) Lookup the PreparedStatement API.

2) Check which arguments are required for the setDate().

3) Try to create those arguments before invoking setDate().

4) If you don't know how to create those arguments, follow the links in the API (i.e. follow the 'Date' link).

5) Read the API of it how to construct it.

BalusCa at 2007-7-12 11:47:59 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
Can someone provide example pls ?tasunny
GloomyProgrammera at 2007-7-12 11:47:59 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

Let's start with 1.

The PreparedStatement API is available here: http://java.sun.com/j2se/1.5.0/docs/api/java/sql/PreparedStatement.html

Now it's also time to bookmark this page: http://java.sun.com/j2se/1.5.0/docs/api/overview-summary.html

You'll going to highly appreciate the API's once you understand it.

BalusCa at 2007-7-12 11:47:59 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

> Can someone provide example pls ?

>

> ta

> sunny

Is it at all possible for you to be any more lazy?

And look up the API for SimpleDateFormat while you are it because that's the real question you have asked in this thread, which by the way has nothing to do with JDBC really. It's the magic String to Date conversion you want.

cotton.ma at 2007-7-12 11:47:59 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
many thanx
GloomyProgrammera at 2007-7-12 11:47:59 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...