Re: AW: AW: Problem with Date/Time-part

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Feb 24 2005 - 16:24:18 EST

  • Next message: Andrus Adamchik: "Re: Mysql -> Date/Time & tracking creation/modification time"

    Ok, then the best thing to do is to submit a bug report in Cayenne Jira.
    Please include SQL DDL to create a table in question and the test code.
    We'll check it out.

    Andrus

    > Hmm.
    >
    > This works (with the same JDBC driver) and gives me the Time part (in
    > the first "println" of course).
    >
    > -->
    >
    > import java.sql.CallableStatement;
    > import java.sql.Connection;
    > import java.sql.DriverManager;
    > import java.sql.ResultSet;
    > import java.sql.SQLException;
    > import java.util.Date;
    >
    >
    > public class Sqltest {
    >
    > public static void main(String[] args) throws SQLException,
    > ClassNotFoundException {
    >
    > CallableStatement cstmt1;
    > Class.forName("oracle.jdbc.driver.OracleDriver");
    > Connection
    > con=DriverManager.getConnection("jdbc:oracle:thin..vu-ora-3:1521:orc1",
    > "comavravr", "ivu");
    >
    > cstmt1 = con.prepareCall(
    > "select * from comdeviceevent where
    > id=71381");
    >
    > ResultSet rs=cstmt1.executeQuery();
    > while (rs.next()){
    > Date d=rs.getTimestamp("txdatetime");
    > System.out.println(d.toLocaleString());
    > d=rs.getDate("txdatetime");
    > System.out.println(d.toLocaleString());
    > }
    > cstmt1.close();
    > }
    > }
    >
    > <--
    >
    > So i'm not so sure that it is not Cayenne related.
    >
    > Regards
    > René
    >
    >> -----Ursprüngliche Nachricht-----
    >> Von: Andrus Adamchik [mailto:andru..bjectstyle.org]
    >> Gesendet: Donnerstag, 24. Februar 2005 19:06
    >> An: cayenne-use..bjectstyle.org
    >> Betreff: Re: AW: Problem with Date/Time-part
    >>
    >> That's a JDBC-level error. At this point I don't think this
    >> is anything Cayenne-related. Check that you have driver
    >> version matching the Oracle version. Try to reproduce the
    >> problem from a test application going directly through JDBC,
    >> and if it still breaks, submit a bug to Oracle.
    >>
    >> Still strange... Cayenne is being tested on Oracle 9i
    >> nightly, and I have never seen this problem...
    >>
    >> Andrus
    >>
    >> > I get the following error:
    >> >
    >> > 24.12 18:12:59,360|[ShutdownHook]|INFO |access.QueryLogger
    >> |
    >> > - select id, comdeviceevnmeth_id, isacknowledge, comdevice_id,
    >> txdatetime, rxdatetime, gpstime, gpslongitude, gpslatitude,
    >> > directionofmotion, velocity, locationangle, locationdescription,
    >> locationdistance, t.indata.getclobval() indata, creation,
    >> creationby,
    >> > modification, modificationby, isdeleted,
    >> comdeviceevnstate_id, tour_id
    >> > from comdeviceevent t where
    >> > t.comdeviceevnstate_id=1 order by
    >> t.comdevice_id,t.txdatetime,t.gpstime
    >> > 24.12 18:12:59,420|[ShutdownHook]|INFO |access.QueryLogger
    >> |
    >> > - *** error.
    >> > java.sql.SQLException: Ungültiger Spaltentyp
    >> > at
    >> oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    >> > at
    >> > oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179) at
    >> oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269) at
    >> >
    >> oracle.jdbc.driver.OracleStatement.getTimestampValue(OracleStatement.j
    >> > ava:498
    >> > 2)
    >> > at
    >> >
    >> oracle.jdbc.driver.OracleResultSetImpl.getTimestamp(OracleResu
    >> ltSetImpl.java:
    >> > 689)
    >> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
    >> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
    >> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
    >> > java.lang.reflect.Method.invoke(Unknown Source)
    >> > at
    >> >
    >> org.objectstyle.cayenne.access.types.DefaultType.materializeObject(Def
    >> > aultTyp
    >> > e.java:243)
    >> > at
    >> >
    >> org.objectstyle.cayenne.access.DefaultResultIterator.readDataRow(Defau
    >> > ltResul
    >> > tIterator.java:250)
    >> > at
    >> >
    >> org.objectstyle.cayenne.access.DefaultResultIterator.nextDataRow(Defau
    >> > ltResul
    >> > tIterator.java:194)
    >> > at
    >> >
    >> org.objectstyle.cayenne.access.DefaultResultIterator.dataRows(DefaultR
    >> > esultIt
    >> > erator.java:224)
    >> > at
    >> >
    >> org.objectstyle.cayenne.access.jdbc.SQLTemplateSelectExecutionPlan.exe
    >> > cute(SQ
    >> > LTemplateSelectExecutionPlan.java:149)
    >> > at
    >> >
    >> org.objectstyle.cayenne.access.DataNode.performQueries(DataNod
    >> e.java:342)
    >> > at
    >> >
    >> org.objectstyle.cayenne.access.DataDomain.performQueries(DataD
    >> omain.java:654)
    >> > at
    >> >
    >> org.objectstyle.cayenne.access.DataContext.performQueries(DataContext.
    >> > java:14
    >> > 08)
    >> > at
    >> >
    >> org.objectstyle.cayenne.access.Transaction.performQueries(Transaction.
    >> > java:17
    >> > 9)
    >> > at
    >> >
    >> org.objectstyle.cayenne.access.DataContext.performQueries(DataContext.
    >> > java:13
    >> > 66)
    >> > at
    >> >
    >> org.objectstyle.cayenne.access.DataContext.performQuery(DataContext.ja
    >> > va:1622
    >> > )
    >> > at
    >> >
    >> org.objectstyle.cayenne.access.DataContext.performQuery(DataContext.ja
    >> > va:1485
    >> > )
    >> > at
    >> >
    >> de.ivu.combitour.dao.ComdeviceeventDAO.findUnprocessed(ComdeviceeventD
    >> > AO.java
    >> > :84)
    >> > at
    >> >
    >> de.ivu.combitour.telematik.CdepController.processEvents(CdepController
    >> > .java:1
    >> > 11)
    >> > at de.ivu.combitour.telematik.Cdep.ProcessIdle(Cdep.java:75)
    >> > at de.ivu.combitour.ShutdownHook$1.run(ShutdownHook.java:25)
    >> >
    >> > Thats the statement:
    >> >
    >> > String sqlStr = "select id, comdeviceevnmeth_id, isacknowledge,
    >> comdevice_id, "
    >> > + "#result('txdatetime'
    >> > 'java.sql.Timestamp'), "
    >> > + "#result('rxdatetime'
    >> > 'java.sql.Timestamp'), "
    >> > + "#result('gpstime'
    >> 'java.sql.Timestamp'),"
    >> > + " gpslongitude, gpslatitude, "
    >> > + "directionofmotion, velocity,
    >> > locationangle, locationdescription, "
    >> > + "locationdistance,
    >> t.indata.getclobval() indata, "
    >> > + "#result('creation'
    >> 'java.sql.Timestamp'), "
    >> > + "creationby, "
    >> > + "#result('modification'
    >> > 'java.sql.Timestamp'), "
    >> > + "modificationby, isdeleted, "
    >> > + "comdeviceevnstate_id, tour_id "
    >> > + "from comdeviceevent t where
    >> > t.comdeviceevnstate_id=1"
    >> > + " order by
    >> > t.comdevice_id,t.txdatetime,t.gpstime";
    >> >
    >> > Regards
    >> > René
    >> >
    >> >> -----Ursprüngliche Nachricht-----
    >> >> Von: Andrus Adamchik [mailto:andru..bjectstyle.org]
    >> >> Gesendet: Donnerstag, 24. Februar 2005 17:58
    >> >> An: cayenne-use..bjectstyle.org
    >> >> Betreff: Re: Problem with Date/Time-part
    >> >>
    >> >> Maybe it doesn't, but Oracle driver is a strange beast.
    >> Could you try
    >> >> using SQLTemplate with a "#result" directive
    >> >> (http://objectstyle.org/cayenne/userguide/fetch/sqltemplate-sc
    >> ripting.html).
    >> >> In your sqlString variable replace all date columns with scriplets
    >> like this one:
    >> >>
    >> >> #result('creation' 'java.sql.Timestamp')
    >> >>
    >> >> Does it change anything?
    >> >>
    >> >> Andrus
    >> >>
    >> >>
    >> >> > Hi,
    >> >> >
    >> >> > This is a sample. But the access method doesnt matter IMHO,
    >> >> even if i
    >> >> > access a object by ObjA.getToObjB() it is the same behaviour.
    >> >> >
    >> >> > -->
    >> >> > public List findUnprocessed() {
    >> >> >
    >> >> > String sqlStr = "select id,
    >> >> comdeviceevnmeth_id, isacknowledge,
    >> >> > comdevice_id, "
    >> >> > + "txdatetime, rxdatetime,
    >> >> gpstime, gpslongitude, gpslatitude, "
    >> >> > + "directionofmotion, velocity,
    >> locationangle,
    >> >> > locationdescription, "
    >> >> > + "locationdistance,
    >> >> t.indata.getclobval() indata, creation, "
    >> >> > + "creationby, modification,
    >> >> modificationby, isdeleted, "
    >> >> > + "comdeviceevnstate_id, tour_id "
    >> >> > + "from comdeviceevent t where
    >> >> > t.comdeviceevnstate_id=1"
    >> >> > + " order by
    >> >> > t.comdevice_id,t.txdatetime,t.gpstime";
    >> >> >
    >> >> > List retval = null;
    >> >> >
    >> >> > DataContext ctx
    >> >> _SingletonDataContext.getInstance().getCtx();
    >> >> >
    >> >> > SQLTemplate rsCde = new
    >> >> SQLTemplate(Comdeviceevent.class, sqlStr,
    >> >> > true);
    >> >> >
    >> >> > retval = ctx.performQuery(rsCde);
    >> >> >
    >> >> > return retval;
    >> >> > }
    >> >> >
    >> >> > <--
    >> >> >
    >> >> >
    >> >> >
    >> >>
    >> >>
    >> >>
    >>
    >>
    >>
    >>



    This archive was generated by hypermail 2.0.0 : Thu Feb 24 2005 - 16:24:20 EST