Mercurial > hg > monetdb-java
annotate tests/BugDecimalRound_Bug_3561.java @ 261:d4baf8a4b43a
Update Copyright year to 2019
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 03 Jan 2019 14:43:44 +0100 (2019-01-03) |
parents | c38d4eaf5479 |
children | 54137aeb1f92 |
rev | line source |
---|---|
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1 /* |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2 * This Source Code Form is subject to the terms of the Mozilla Public |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
5 * |
261
d4baf8a4b43a
Update Copyright year to 2019
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
7 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
8 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
9 import java.sql.*; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
10 import java.math.BigDecimal; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
11 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
12 public class BugDecimalRound_Bug_3561 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
13 public static void main(String[] args) throws Exception { |
27
04fbf3655452
Disable Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); code
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
14 // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
15 Connection con = DriverManager.getConnection(args[0]); |
122
8b13d0941c61
Extended test for pstmt.setBigDecimal() with two more decmal values which will be rounded.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
16 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
17 Statement stmt1 = con.createStatement(); |
122
8b13d0941c61
Extended test for pstmt.setBigDecimal() with two more decmal values which will be rounded.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
18 stmt1.executeUpdate("CREATE TABLE bug3561 (d decimal(14,4))"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
19 |
122
8b13d0941c61
Extended test for pstmt.setBigDecimal() with two more decmal values which will be rounded.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
20 PreparedStatement st = con.prepareStatement("INSERT INTO bug3561 VALUES (?)"); |
8b13d0941c61
Extended test for pstmt.setBigDecimal() with two more decmal values which will be rounded.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
21 st.setBigDecimal(1, new BigDecimal("112.125")); |
8b13d0941c61
Extended test for pstmt.setBigDecimal() with two more decmal values which will be rounded.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
22 st.executeUpdate(); |
8b13d0941c61
Extended test for pstmt.setBigDecimal() with two more decmal values which will be rounded.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
23 st.setBigDecimal(1, new BigDecimal("212.12345")); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
24 st.executeUpdate(); |
122
8b13d0941c61
Extended test for pstmt.setBigDecimal() with two more decmal values which will be rounded.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
25 st.setBigDecimal(1, new BigDecimal("0.012345")); |
8b13d0941c61
Extended test for pstmt.setBigDecimal() with two more decmal values which will be rounded.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
26 st.executeUpdate(); |
8b13d0941c61
Extended test for pstmt.setBigDecimal() with two more decmal values which will be rounded.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
27 st.close(); |
8b13d0941c61
Extended test for pstmt.setBigDecimal() with two more decmal values which will be rounded.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
28 |
8b13d0941c61
Extended test for pstmt.setBigDecimal() with two more decmal values which will be rounded.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
29 Statement stmt2 = con.createStatement(); |
8b13d0941c61
Extended test for pstmt.setBigDecimal() with two more decmal values which will be rounded.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
30 ResultSet rs = stmt2.executeQuery("SELECT d FROM bug3561"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
31 while (rs.next()) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
32 System.out.println(rs.getString(1)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
33 rs.close(); |
122
8b13d0941c61
Extended test for pstmt.setBigDecimal() with two more decmal values which will be rounded.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
34 stmt2.close(); |
8b13d0941c61
Extended test for pstmt.setBigDecimal() with two more decmal values which will be rounded.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
35 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
36 stmt1.executeUpdate("DROP TABLE bug3561"); |
122
8b13d0941c61
Extended test for pstmt.setBigDecimal() with two more decmal values which will be rounded.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
37 stmt1.close(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
38 con.close(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
39 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
40 } |