Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v7.1
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Cobol v5.0
  HXTT DBF v7.1
  HXTT Excel v6.1
  HXTT Json v1.0
  HXTT Paradox v7.1
  HXTT PDF v2.0
  HXTT Text(CSV) v7.1
  HXTT Word v1.1
  HXTT XML v4.0
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
Currency Data Type messes up the decimal digits
Govind
2013-06-20 08:20:08
Hi,
We are noticing that the Currency Data Type does not work properly with the HXTT driver.

Please find the sample program attached which inserts and retrieves values from a Currency Field. Notice that the decimal digits are fluctuating for some reason.

import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;

public class testPreparedStatementAccess
{
public static void main(String argv[])
{

try
{
Class.forName("com.hxtt.sql.access.AccessDriver").newInstance();
Connection connection = DriverManager.getConnection("jdbc:access:/C:\\Access\\DataTypes.accdb");


String createTable = "Drop table if exists [CurrencyTestTable]";
Statement stmt = connection.createStatement();
stmt.execute(createTable);
connection.commit();
stmt.close();

createTable = "CREATE TABLE [CurrencyTestTable] ([MoneyField] OTHER(Currency) )";
stmt = connection.createStatement();
stmt.execute(createTable);
connection.commit();
stmt.close();

PreparedStatement ps = null;
String sql = "INSERT INTO [CurrencyTestTable] (MoneyField ) VALUES ( ? )";
ps = connection.prepareStatement(sql);

String[] value = {"15624372223167.8413","63478118456360.54","56881394037433.556","77005005610025.1372","15624372223167.8013"};
BigDecimal currencyValue[] = new BigDecimal[value.length];
for (int i=0 ; i < currencyValue.length ; i++) {
currencyValue[i]= new BigDecimal(value[i]);

System.out.println("Stored currency value is : "+ currencyValue[i]);
ps.setBigDecimal(1, currencyValue[i]);
ps.execute();
}
ps.close();

System.out.println("====================================");
String select = "Select MoneyField from CurrencyTestTable ";
ResultSet rs = connection.createStatement().executeQuery(select);

while (rs.next()) {
System.out.println("Retrieved currency value is : "+ rs.getObject(1));
}
rs.close();
connection.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}


This results in the output ::::


Stored currency value is : 15624372223167.8413
Stored currency value is : 63478118456360.54
Stored currency value is : 56881394037433.556
Stored currency value is : 77005005610025.1372
Stored currency value is : 15624372223167.8013
====================================
Retrieved currency value is : 15624372223167.8438
Retrieved currency value is : 63478118456360.5391
Retrieved currency value is : 56881394037433.5547
Retrieved currency value is : 77005005610025.1406
Retrieved currency value is : 15624372223167.8008



A similar test against MSSQL MONEY Data Type field returns the following results.

Stored currency value is : 15624372223167.8413
Stored currency value is : 63478118456360.54
Stored currency value is : 56881394037433.556
Stored currency value is : 77005005610025.1372
Stored currency value is : 15624372223167.8013
====================================
Retrieved currency value is : 15624372223167.8413
Retrieved currency value is : 63478118456360.5400
Retrieved currency value is : 56881394037433.5560
Retrieved currency value is : 77005005610025.1372
Retrieved currency value is : 15624372223167.8013


Please let me know in case I've overlooked anything. Thank you.

Re:Currency Data Type messes up the decimal digits
Govind
2013-06-24 08:01:46
Hi, Can you please give me an update on this?
Re:Re:Currency Data Type messes up the decimal digits
HXTT Support
2013-06-25 06:40:37
Supported. Please download it.

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