Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

getTimestamp(int) returning null when values exist.

843859Jun 8 2010 — edited Nov 20 2014
Hi

I'm continually getting 'null' being returned by the getTimeStamp(int) method from a ResultSet.

If I run the stored proc with the required parameters in SQL server, it returns values for the field. Its a DateTime field - so should return this when my code calls it, right?

Here is a snippet of the code:
      try {
            conn = datasrc.getConnection();
            cs = conn.prepareCall("{call rsp_employee_get(?,?)}");
            cs.setInt(1, id);
            cs.setString(2, name);
            rs = cs.executeQuery();
 
            if(rs.next()) {
                
                employee = new Employee();
                employee.setManagerId(rs.getInt(1));
                employee.setOccupationId(rs.getInt(2));
                employee.setJobTitle(rs.getString(3));
                employee.setPreferredName(rs.getString(4));
                employee.setWorkedFromDate(rs.getTimestamp(5));
                employee.setWorkedToDate(rs.getTimestamp(6));             //this is where my error occurs
All objects etc have been created correctly, and obviously above is only a snippet.

The proc returns values as expected, and rs.getTimestamp(5) works fine - however these dates all have the time 00:00:00.000 whereas the field getTimestamp(6) refers to have times of 23:59:59.000... (could this be it??)

The proc returns a list of employees off the database, past and present - so some do have null values for this field (ie they're current employees) - however, I've checked and its recording them all as null even though they're not null when I run the proc manually.

I'm getting a bit fed up with it to be honest, hoping someone here has seen it before and can see if I've done something wrong?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 9 2010
Added on Jun 8 2010
7 comments
1,254 views