Results 1 to 4 of 4
  1. #1
    sm123 is offline Member
    Join Date
    Mar 2010
    Posts
    11
    Rep Power
    0

    Default Reading timestamp value from Oracle database using Java Spring

    Hi,

    I am using spring to retrieve data from a table called RULE. The class rule.java is the POJO class used to store the data retrieved from database.

    I am able to retrieve all data except the column which is defined as TIMESTAMP(6) in database. When I say:

    rule.getDeployedDate()

    it returns null rather than the actual value from database. The method in POJO class is defined as below:

    public java.sql.Timestamp getDeployDate() {
    return deployDate;
    }


    public void setDeployDate(TimestampdeployDate) {
    this.deployDate = deployDate;
    }

    Please help.Whic datatype should be used for getting date.

    Thanks,

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default

    I would imagine it would throw an exception if you attempted to assign it incorrectly (ie if the method signature was not what Spring expected), so I would ask what the mapping looks like. I can't quite remember how Spring does it, but if you post what it does I'll remember quickly enough.

  3. #3
    sm123 is offline Member
    Join Date
    Mar 2010
    Posts
    11
    Rep Power
    0

    Default

    It uses the ParameterizedBeanPropertyRowMapper class for mapping.

    public BrokerRule findBrokerRuleByPk(String ruleID, String brokerID, int version) {
    Object[] obj = new Object[] { ruleID, brokerID, version };
    try {
    return (BrokerRule) getJdbcTemplate()
    .queryForObject(
    "SELECT * FROM AUDITOR_RULE AR WHERE AR.ID=? AND AR.BROKER_ID=? AND AR.VERSION=?",
    obj,
    ParameterizedBeanPropertyRowMapper
    .newInstance(BrokerRule.class));
    } catch (Exception e) {
    return null;
    }

    }

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default

    For starters at the very least print the stack trace when catching that exception.
    Now, does that RowMapper use the names of the columns to map against the objects attributes? If not then how is it mapped?
    (I think I used one of the other Mappers when I did all this)

Similar Threads

  1. Replies: 9
    Last Post: 01-17-2012, 08:31 AM
  2. Spring, iBatis and multiple Oracle tablespaces
    By richteri in forum Web Frameworks
    Replies: 1
    Last Post: 01-26-2010, 08:26 AM
  3. Send object via web service, with a java.sql.Timestamp attribute
    By diegofsza in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 08-15-2009, 11:40 PM
  4. How to Load Java Object into Oracle Database
    By dorairaj in forum Advanced Java
    Replies: 3
    Last Post: 01-12-2009, 02:37 PM
  5. How to insert java Object in oracle database
    By Thilkumar82 in forum Advanced Java
    Replies: 9
    Last Post: 08-13-2008, 11:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •