tags:

views:

45

answers:

2

Hi to all!

I have the following situation...

I use CallableStatement from java.sql package. When I use setDate function prior to executing stored procedure, I get an error:

Cannot find symbol symbol: method setDate(int, java.util.Date) location: interface java.sql.CallableStatement"

Here's the sample code:

Connection con = null;
CallableStatement proc_stmt = null;

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

con = DriverManager.getConnection("jdbc:sqlserver://servername;databaseName=DBName", "UNAME", "PASS");

proc_stmt = con.prepareCall("{ call InsertSomething(?, ?) }");

proc_stmt.setString(1, "A00999999");
proc_stmt.setDate(2, new Date());

proc_stmt.executeQuery();

proc_stmt.close();
con.close();

I even tried this using Calendar class with appropriate functions, but the effect was the same.

+3  A: 

It must be a java.sql.Date, a sub-class of java.util.Date

Sinuhe
You've beaten me by 5 secs :-)
NickDK
Thanx a lot, this is it:D;)
Eedoh
You're welcome, Eedoh. NickDK: better luck next time ;)
Sinuhe
+2  A: 

You should use the java.sql.Date class instead of the java.util.Date class.

NickDK