Mercurial > hg > monetdb-java
changeset 122:8b13d0941c61
Extended test for pstmt.setBigDecimal() with two more decmal values which will be rounded.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 09 Mar 2017 18:11:56 +0100 (2017-03-09) |
parents | 65b27b29ca71 |
children | 206a2cb51b65 |
files | tests/BugDecimalRound_Bug_3561.java |
diffstat | 1 files changed, 15 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/BugDecimalRound_Bug_3561.java +++ b/tests/BugDecimalRound_Bug_3561.java @@ -13,22 +13,28 @@ public class BugDecimalRound_Bug_3561 { public static void main(String[] args) throws Exception { // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); + Statement stmt1 = con.createStatement(); - PreparedStatement st; - Statement stmt2; - ResultSet rs; - BigDecimal bd = new BigDecimal("112.125"); + stmt1.executeUpdate("CREATE TABLE bug3561 (d decimal(14,4))"); - stmt1.executeUpdate("CREATE TABLE bug3561 (d decimal(14,4))"); - st = con.prepareStatement("INSERT INTO bug3561 VALUES (?)"); - st.setBigDecimal(1, bd); + PreparedStatement st = con.prepareStatement("INSERT INTO bug3561 VALUES (?)"); + st.setBigDecimal(1, new BigDecimal("112.125")); + st.executeUpdate(); + st.setBigDecimal(1, new BigDecimal("212.12345")); st.executeUpdate(); - stmt2 = con.createStatement(); - rs = stmt2.executeQuery("SELECT d FROM bug3561"); + st.setBigDecimal(1, new BigDecimal("0.012345")); + st.executeUpdate(); + st.close(); + + Statement stmt2 = con.createStatement(); + ResultSet rs = stmt2.executeQuery("SELECT d FROM bug3561"); while (rs.next()) System.out.println(rs.getString(1)); rs.close(); + stmt2.close(); + stmt1.executeUpdate("DROP TABLE bug3561"); + stmt1.close(); con.close(); } }