Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access 7.1.131
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Cobol 5.0.131
  HXTT DBF 7.1.132
  HXTT Excel 6.1.135
  HXTT Json 1.0.103
  HXTT Paradox 7.1.131
  HXTT PDF 2.0.131
  HXTT Text(CSV) 7.1.131
  HXTT Word 1.1.131
  HXTT XML 4.0.132
Offshore Outsourcing
Free Resources
  Firewall Tunneling
  Search Indexing Robot
  Conditional Compilation
  Password Recovery for MS Access
  Password Recovery for Corel Paradox
  Checksum Tool for MD5
  Character Set Converter
  Pyramid - Poker of ZYH
   
   
   
Heng Xing Tian Tai Lab of Xi'an City (abbr, HXTT)

HXTT ACCESS
Access JDBC jars issue
Amit
2010-06-10 08:23:10.0
Hi,

We are using the latest access-jdbc jars (i.e. 3.2.127). The issue which we are facing is related to timezone .We are reading the data from access table the code is as follows

Properties props = new Properties();
props.setProperty("timezone", "local");
connection = DriverManager.getConnection(connectionURL,props);
statement = connection.createStatement();

and expecting it to read the data as it is seen in the file i.e. in GMT format. But it doesnt happen.

Re:Access JDBC jars issue
HXTT Support
2010-06-10 17:42:34.0
The latest package is v4.0.005. Please download it.
If you cann't see with
props.setProperty("timezone", "local");
you can try
props.setProperty("timezone", "GMT");
Re:Re:Access JDBC jars issue
Amit
2010-06-18 00:17:04.0
The interesting thing I have found with the same jars which I was using (i.e. 3.2.127) , Currently we use

calendar1 = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
resultSet.getDate(i, calendar1);

reading like this is a problem. If i dont use the calendar instance in resultSet.GetDate() it reads up the date correctly.

This piece of code we were using with old access-jdbc jars. After upgrade this issue started coming in. For reproducing I am setting my machine's timezone to EST and reading it.
Re:Re:Re:Access JDBC jars issue
HXTT Support
2010-06-18 00:33:00.0
>If i dont use the calendar instance in resultSet.GetDate() it reads up the
>date correctly.
1. Without timezone connection property setting, ResultSet.getDate(i) should return Date in local timezone,and ResultSet.getDate(i,gmdCalendar) return Date in GMT timezone.

2. With timezone=GMT connection property setting, ResultSet.getDate(i) and ResultSet.getDate(i,gmdCalendar) should return Date in GMT timezone.

Re:Re:Re:Re:Access JDBC jars issue
Amit
2010-06-18 02:46:57.0
Yes this is the ideal behavior but its not happening in this way. Only if i ues getDate() without calendar instance it works as expected. Else in all other scenarios it doesn't
Re:Re:Re:Re:Re:Access JDBC jars issue
HXTT Support
2010-06-18 04:22:50.0
Passed test with the following code:

package test.jdbc.access;

import java.sql.*;
import java.util.Properties;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;

public class testCalendar5 {
public static void main(String[] args) throws Exception {
try{
test(null);
test("GMT");
test("local");
}
catch( SQLException sqle )
{
do
{
System.out.println(sqle.getMessage());
System.out.println("Error Code:"+sqle.getErrorCode());
System.out.println("SQL State:"+sqle.getSQLState());
sqle.printStackTrace();
}while((sqle=sqle.getNextException())!=null);
}
catch( Exception e )
{
System.out.println(e.getMessage());
e.printStackTrace();
}
}

public static void test(String timeZone) throws Exception {
TimeZone newZone;
if(timeZone==null || "local".equals(timeZone)){
newZone=TimeZone.getDefault();
}else{
newZone=TimeZone.getTimeZone(timeZone);
}
TimeZone.setDefault(newZone);
Calendar calendar = Calendar.getInstance();

Class.forName("com.hxtt.sql.access.AccessDriver");
String jdbcConnection = "jdbc:access:/d:/test/access";

Properties props = new Properties();
props.setProperty("versionNumber", "JET4");
if(timeZone!=null){
props.setProperty("timezone", timeZone);
}



Connection conn = DriverManager.getConnection(jdbcConnection, props);
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

boolean createflage=stmt.executeUpdate("create database if not exists testcalendar;")>0;
conn.setCatalog("testcalendar");

if(createflage){
stmt.execute("create table if not exists test (date1 date);");
stmt.execute("insert into test values('2010-05-10');");
stmt.execute("insert into test values(now());");
}

System.out.println("timeZone:"+timeZone);
ResultSet rs = stmt.executeQuery("select * from test");
while(rs.next()) {
System.out.println(rs.getDate("date1"));
System.out.println(rs.getDate("date1",calendar));
System.out.println(rs.getTimestamp("date1"));
System.out.println(rs.getTimestamp("date1",calendar));
}

rs.close();
stmt.close();

conn.close();
}
}



BTW, MS Access is stored timestamp based on GMT, and different calendar setting will return different date value.

Search Key   Search by Last 50 Questions




Google
 

Email: webmaster@hxtt.com
Copyright © 2003-2019 Heng Xing Tian Tai Lab of Xi'an City. | All Rights Reserved. | Privacy | Legal | Sitemap