assigning ResultSet.getDate()

I am using ResultSet.getDate() to get a date field from MSSQL Server database. What variable type do I best assign the returned value to? getDate() returns a java.sql.Date object.I need to adjest date to account for time zone differences then return adjusted date to dbase.

Have tried

java.sql.Date cDate = rs.getDate("CDateTime");

CDateTime is the name of the field in dbase, but I get an

error thrown at this line as:

java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index

Would appreciate any comments on best way to assign rs.getDate().

Any comments on why this error is thrown? I have double checked that field name used is correct.

[729 byte] By [tully4] at [2007-9-26 2:50:33]
# 1
Are you sure in the column name? What is you select look like?
dsklyut at 2007-6-29 10:37:12 > top of Java-index,Archived Forums,Java Programming...
# 2

My select statement:

String sql = "SELECT * FROM \"CallRecd\"";

ResultSet rs = stmt.executeQuery(sql);

Yes column name is correct, double checked this.

Just realised this post should be in JDBC forum.

Don't know how to transfer it there. (I'm a newbie here !)

tully4 at 2007-6-29 10:37:12 > top of Java-index,Archived Forums,Java Programming...
# 3

Instead of saying SELECT * from; specify a list of columns. Try to do this:

get a result set metadata and coolate through that getting all of the column names and print them out. See what you got that way. Select * should work, but I don't like using select *, I would recomend specifying the list of columns.

dsklyut at 2007-6-29 10:37:12 > top of Java-index,Archived Forums,Java Programming...