Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v5.2
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Cobol v2.1
  HXTT DBF v5.2
  HXTT Excel v4.2
  HXTT Paradox v5.2
  HXTT Text(CSV) v5.2
  HXTT XML v1.2
Offshore Outsourcing
Oracle Data Import/Export
DB2 Data Import/Export
Sybase Data Import/Export
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
   
   
   
Hongxin Technology & Trade Ltd. of Xiangtan City (abbr, HXTT)

HXTT ACCESS
Currency Data Type messes up the decimal digits
Govind
2013-06-20 08:20:08.0
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.0
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.0
Supported. Please download it.

Search Key   Search by Last 50 Questions




Google
 

Address: 9 Station Rd., Xiangtan City, Hunan Province, P.R. China
Postcode: 411100
Phone: (86)731-58225727
Fax: (86)731-58225727
Email: webmaster@hxtt.com
Copyright © 1999-2011 Hongxin Technology & Trade Ltd. | All Rights Reserved. | Privacy | Legal | Sitemap