Mercurial > hg > monetdb-java
comparison src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java @ 286:d430f8adbf1b
Add keyword "final" to those variables which do not change after first assigment.
In MonetConnection.java corrected size of array (was 7): isSet = new boolean[4];
In MonetPreparedStatement.java removed variable connection as it is already present in superclass MonetStatement (changed it into protected).
In MonetResultSet.java sinplified code for assigning Connection conn and DatabaseMetaData dbmd. It is now done on instantiation. This allows them to become "final".
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 25 Jul 2019 19:04:10 +0200 (2019-07-25) |
parents | 637899bda602 |
children | 2ad7f42f141d f412032e3b43 |
comparison
equal
deleted
inserted
replaced
285:637899bda602 | 286:d430f8adbf1b |
---|---|
1931 /** The query sequence number */ | 1931 /** The query sequence number */ |
1932 private final int seqnr; | 1932 private final int seqnr; |
1933 /** A List of result blocks (chunks of size fetchSize/cacheSize) */ | 1933 /** A List of result blocks (chunks of size fetchSize/cacheSize) */ |
1934 private DataBlockResponse[] resultBlocks; | 1934 private DataBlockResponse[] resultBlocks; |
1935 | 1935 |
1936 /** A bitmap telling whether the headers are set or not */ | |
1937 private boolean[] isSet; | |
1938 /** Whether this Response is closed */ | 1936 /** Whether this Response is closed */ |
1939 private boolean closed; | 1937 private boolean closed; |
1940 | 1938 |
1941 /** The Connection that we should use when requesting a new block */ | 1939 /** The Connection that we should use when requesting a new block */ |
1942 private MonetConnection.ResponseList parent; | 1940 private final MonetConnection.ResponseList parent; |
1943 /** Whether the fetchSize was explitly set by the user */ | 1941 /** Whether the fetchSize was explitly set by the user */ |
1944 private boolean cacheSizeSetExplicitly = false; | 1942 private boolean cacheSizeSetExplicitly = false; |
1945 /** Whether we should send an Xclose command to the server | 1943 /** Whether we should send an Xclose command to the server |
1946 * if we close this Response */ | 1944 * if we close this Response */ |
1947 private boolean destroyOnClose; | 1945 private boolean destroyOnClose; |
1949 private int blockOffset = 0; | 1947 private int blockOffset = 0; |
1950 | 1948 |
1951 /** A parser for header lines */ | 1949 /** A parser for header lines */ |
1952 HeaderLineParser hlp; | 1950 HeaderLineParser hlp; |
1953 | 1951 |
1952 /** A boolean array telling whether the headers are set or not */ | |
1953 private final boolean[] isSet; | |
1954 private static final int NAMES = 0; | 1954 private static final int NAMES = 0; |
1955 private static final int TYPES = 1; | 1955 private static final int TYPES = 1; |
1956 private static final int TABLES = 2; | 1956 private static final int TABLES = 2; |
1957 private static final int LENS = 3; | 1957 private static final int LENS = 3; |
1958 | 1958 |
1976 int rowcount, | 1976 int rowcount, |
1977 MonetConnection.ResponseList parent, | 1977 MonetConnection.ResponseList parent, |
1978 int seq) | 1978 int seq) |
1979 throws SQLException | 1979 throws SQLException |
1980 { | 1980 { |
1981 isSet = new boolean[7]; | 1981 isSet = new boolean[4]; |
1982 this.parent = parent; | 1982 this.parent = parent; |
1983 if (parent.cachesize == 0) { | 1983 if (parent.cachesize == 0) { |
1984 /* Below we have to calculate how many "chunks" we need | 1984 /* Below we have to calculate how many "chunks" we need |
1985 * to allocate to store the entire result. However, if | 1985 * to allocate to store the entire result. However, if |
1986 * the user didn't set a cache size, as in this case, we | 1986 * the user didn't set a cache size, as in this case, we |
2006 destroyOnClose = id > 0 && tuplecount > rowcount; | 2006 destroyOnClose = id > 0 && tuplecount > rowcount; |
2007 | 2007 |
2008 this.id = id; | 2008 this.id = id; |
2009 this.tuplecount = tuplecount; | 2009 this.tuplecount = tuplecount; |
2010 this.columncount = columncount; | 2010 this.columncount = columncount; |
2011 this.resultBlocks = | 2011 this.resultBlocks = new DataBlockResponse[(tuplecount / cacheSize) + 1]; |
2012 new DataBlockResponse[(tuplecount / cacheSize) + 1]; | |
2013 | 2012 |
2014 hlp = new HeaderLineParser(columncount); | 2013 hlp = new HeaderLineParser(columncount); |
2015 | 2014 |
2016 resultBlocks[0] = new DataBlockResponse( | 2015 resultBlocks[0] = new DataBlockResponse(rowcount, parent.rstype == ResultSet.TYPE_FORWARD_ONLY); |
2017 rowcount, | |
2018 parent.rstype == ResultSet.TYPE_FORWARD_ONLY | |
2019 ); | |
2020 } | 2016 } |
2021 | 2017 |
2022 /** | 2018 /** |
2023 * Parses the given string and changes the value of the matching | 2019 * Parses the given string and changes the value of the matching |
2024 * header appropriately, or passes it on to the underlying | 2020 * header appropriately, or passes it on to the underlying |