Problem with Informix JDBC, MONEY and decimal separator in string literals

后端 未结 2 1097
刺人心
刺人心 2021-01-22 21:57

I have problem with JDBC application that uses MONEY data type. When I insert into MONEY column:

insert into _money_test (amt) values (\'123.45\')
2条回答
  •  情深已故
    2021-01-22 22:33

    I solved this problem by using PreparedStatement. I think that "Character to numeric conversion error" is a bug in Informix JDBC driver.

    In other database I often use, PostgreSQL, there is no difference if I run query via native JDBC driver or via JDBC-ODBC bridge. I found that PostgreSQL do not accept numeric form 123.45. PostgreSQL accepts string literal with dot, but this dot is handled as a thousand separator. The only correctly accepted value is string literal where comma separates decimal part.

    EDIT:

    It can be solved by setting DBMONEY=. on server side, then all connections (ODBC, JDBC) will work with that setting.

提交回复
热议问题