Am Donnerstag, 21. April 2005 23:49 schrieben Sie: > Ingolf Knopf wrote: > > The following bug has been logged online: > > > > Bug reference: 1611 > > Logged by: Ingolf Knopf > > Email address: [EMAIL PROTECTED] > > PostgreSQL version: 8.0.1 > > Operating system: JDBC > > Description: reading a date-field by "ResultSet.getTimestamp()" > > method analized dayligth flag > > Details: > > > > Retrieving data by "java.sql.ResultSet" I read a data from a column which > > has type DATE. I read content of this column by method > > "ResultSet.getTimestamp( int )". > > I get a "java.sql.Timestamp"-object, where Calendar.HOUR_OF_DAY==1. I > > suppose, this is daylight flag. > > > > Maybe this behavior of your JDBC driver is compatible with SQL standard, > > but it is completely other than the behavior of "Oracle" or "Ingres". > > Can you provide a compilable test case please? > > What is the behaviour of Oracle/Ingres with the same test case? > > -O
See attached file. The problem you can find in method 'run( void )'. Output of my program is: DBMS==PostgreSQL: problem! dCal==java.util.GregorianCalendar[time=1114120800000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/Berlin",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=143,lastRule=java.util.SimpleTimeZone[id=Europe/Berlin,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2005,MONTH=3,WEEK_OF_YEAR=16,WEEK_OF_MONTH=3,DAY_OF_MONTH=22,DAY_OF_YEAR=112,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=4,AM_PM=0,HOUR=0,HOUR_OF_DAY=0,MINUTE=0,SECOND=0,MILLISECOND=0,ZONE_OFFSET=3600000,DST_OFFSET=3600000] tCal==java.util.GregorianCalendar[time=1114124400000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/Berlin",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=143,lastRule=java.util.SimpleTimeZone[id=Europe/Berlin,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2005,MONTH=3,WEEK_OF_YEAR=16,WEEK_OF_MONTH=3,DAY_OF_MONTH=22,DAY_OF_YEAR=112,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=4,AM_PM=0,HOUR=1,HOUR_OF_DAY=1,MINUTE=0,SECOND=0,MILLISECOND=0,ZONE_OFFSET=3600000,DST_OFFSET=3600000] DBMS==Oracle: no problem! dCal==java.util.GregorianCalendar[time=1114120800000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/Berlin",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=143,lastRule=java.util.SimpleTimeZone[id=Europe/Berlin,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2005,MONTH=3,WEEK_OF_YEAR=16,WEEK_OF_MONTH=3,DAY_OF_MONTH=22,DAY_OF_YEAR=112,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=4,AM_PM=0,HOUR=0,HOUR_OF_DAY=0,MINUTE=0,SECOND=0,MILLISECOND=0,ZONE_OFFSET=3600000,DST_OFFSET=3600000] DBMS==Ingres: no problem! dCal==java.util.GregorianCalendar[time=1114120800000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/Berlin",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=143,lastRule=java.util.SimpleTimeZone[id=Europe/Berlin,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2005,MONTH=3,WEEK_OF_YEAR=16,WEEK_OF_MONTH=3,DAY_OF_MONTH=22,DAY_OF_YEAR=112,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=4,AM_PM=0,HOUR=0,HOUR_OF_DAY=0,MINUTE=0,SECOND=0,MILLISECOND=0,ZONE_OFFSET=3600000,DST_OFFSET=3600000]
package de.csc_dd.postgres.test1611; import java.sql.Connection; import java.sql.Date; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.sql.Timestamp; import java.util.Calendar; public class RsetDemo { /** * Creates a connection depending of the name of the required DMBS and saves this * into [EMAIL PROTECTED] #vConn}. * * @param pDbmsName * Name of required DBMS. Can be one of [EMAIL PROTECTED] #C_DBMSNAME_INGRES}, * [EMAIL PROTECTED] #C_DBMSNAME_ORACLE} or [EMAIL PROTECTED] #C_DBMSNAME_POSTGRES}. * @throws ClassNotFoundException * if not postgres driver found in classpath * @throws SQLException * if any case of sql error */ public RsetDemo( final String pDbmsName ) throws ClassNotFoundException, SQLException { if ( C_DBMSNAME_POSTGRES.equals( pDbmsName ) ) { // creates a connection to postgres database Class.forName( "org.postgresql.Driver" ); vConn = DriverManager.getConnection( "jdbc:postgresql://helena:5432/marl21", "webappl", "..." ); } else if ( C_DBMSNAME_ORACLE.equals( pDbmsName ) ) { // creates a connection to postgres database Class.forName( "oracle.jdbc.driver.OracleDriver" ); vConn = DriverManager.getConnection( "jdbc:oracle:thin:@yade9:1521:YADE9", "marl21", "..." ); } else if ( C_DBMSNAME_INGRES.equals( pDbmsName ) ) { // creates a connection to postgres database Class.forName( "ca.ingres.jdbc.IngresDriver" ); vConn = DriverManager.getConnection( "jdbc:ingres://ingres30l:I37/neuss21", "oesdba", "..." ); } else { throw new IllegalArgumentException( "no connect-params configured for pDbmsName==" + pDbmsName ); } // set autocommit of and save symbolic name of dbms vConn.setAutoCommit( false ); vDbmsName = pDbmsName; } private void run() throws SQLException { // creates a simple table for demonstration String sql_createTable = " CREATE TABLE demo_table_1611 " + " ( date_column DATE ) " ; Statement stmt = vConn.createStatement(); stmt.execute( sql_createTable ); // inserts a date value String sql_insertValue = " INSERT INTO demo_table_1611 " + " ( date_column )" + " VALUES " + " ( ? ) " ; PreparedStatement pstmt = vConn.prepareStatement( sql_insertValue ); pstmt.setDate( 1, new Date( System.currentTimeMillis() ) ); pstmt.executeUpdate(); pstmt.close(); // read data String sql_readData = " SELECT date_column " + " FROM demo_table_1611 " ; ResultSet rset = stmt.executeQuery( sql_readData ); if ( rset.next() ) { Date dVal = rset.getDate( 1 ); Timestamp tVal = rset.getTimestamp( 1 ); Calendar dCal = Calendar.getInstance(); dCal.setTime( dVal ); Calendar tCal = Calendar.getInstance(); tCal.setTime( tVal ); if ( dCal.equals( tCal ) ) { System.out.println( "DBMS=="+vDbmsName+": no problem!" ); System.out.println( "dCal==" + dCal ); } else { System.err.println( "DBMS=="+vDbmsName+": problem!" ); System.err.println( "dCal==" + dCal ); System.err.println( "tCal==" + tCal ); } } rset.close(); // drop the table an commits session String sql_dropTable = " DROP TABLE demo_table_1611 " ; stmt.execute( sql_dropTable ); vConn.commit(); } /** * Closes the connection stored in [EMAIL PROTECTED] #vConn}. */ public void closeConnection() throws SQLException { if ( null != vConn ) vConn.close(); vConn = null; } /** * Closes the connection stored in [EMAIL PROTECTED] #vConn}, if still not done. */ public void finalize() throws Throwable { closeConnection(); super.finalize(); } /** * Runs the demo. * * @param pArgv * @throws ClassNotFoundException * @throws SQLException */ public static void main( String [] pArgv ) throws ClassNotFoundException, SQLException { RsetDemo demo; demo = new RsetDemo( C_DBMSNAME_POSTGRES ); demo.run(); demo.closeConnection(); demo = new RsetDemo( C_DBMSNAME_ORACLE ); demo.run(); demo.closeConnection(); demo = new RsetDemo( C_DBMSNAME_INGRES ); demo.run(); demo.closeConnection(); } public static final String C_DBMSNAME_ORACLE = "Oracle"; public static final String C_DBMSNAME_INGRES = "Ingres"; public static final String C_DBMSNAME_POSTGRES = "PostgreSQL"; private String vDbmsName; private Connection vConn; }
---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])