comparison tests/BugDecimalRound_Bug_3561.java @ 0:a5a898f6886c

Copy of MonetDB java directory changeset e6e32756ad31.
author Sjoerd Mullender <sjoerd@acm.org>
date Wed, 21 Sep 2016 09:34:48 +0200 (2016-09-21)
parents
children 04fbf3655452
comparison
equal deleted inserted replaced
-1:000000000000 0:a5a898f6886c
1 /*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 *
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
7 */
8
9 import java.sql.*;
10 import java.math.BigDecimal;
11
12 public class BugDecimalRound_Bug_3561 {
13 public static void main(String[] args) throws Exception {
14 Class.forName("nl.cwi.monetdb.jdbc.MonetDriver");
15 Connection con = DriverManager.getConnection(args[0]);
16 Statement stmt1 = con.createStatement();
17 PreparedStatement st;
18 Statement stmt2;
19 ResultSet rs;
20 BigDecimal bd = new BigDecimal("112.125");
21
22 stmt1.executeUpdate("CREATE TABLE bug3561 (d decimal(14,4))");
23 st = con.prepareStatement("INSERT INTO bug3561 VALUES (?)");
24 st.setBigDecimal(1, bd);
25 st.executeUpdate();
26 stmt2 = con.createStatement();
27 rs = stmt2.executeQuery("SELECT d FROM bug3561");
28 while (rs.next())
29 System.out.println(rs.getString(1));
30 rs.close();
31 stmt1.executeUpdate("DROP TABLE bug3561");
32 con.close();
33 }
34 }