Mercurial > hg > monetdb-java
comparison src/main/java/org/monetdb/jdbc/MonetConnection.java @ 472:0e21097f438b
Reduce the number of MonetDatabaseMetaData objects created via getMetaData() to maximum 1 per connection as it can be reused.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Fri, 30 Apr 2021 17:23:16 +0200 (2021-04-30) |
parents | 3dfcd06fd8ba |
children | d414e5c4470c |
comparison
equal
deleted
inserted
replaced
471:e14e81b8044e | 472:0e21097f438b |
---|---|
145 private boolean treatClobAsVarChar = true; // turned on by default for optimal performance (from JDBC Driver release 2.30 onwards) | 145 private boolean treatClobAsVarChar = true; // turned on by default for optimal performance (from JDBC Driver release 2.30 onwards) |
146 | 146 |
147 /** The last set query timeout on the server as used by Statement, PreparedStatement and CallableStatement */ | 147 /** The last set query timeout on the server as used by Statement, PreparedStatement and CallableStatement */ |
148 protected int lastSetQueryTimeout; // 0 means no timeout, which is the default on the server | 148 protected int lastSetQueryTimeout; // 0 means no timeout, which is the default on the server |
149 | 149 |
150 /** A cache to reduce the number of DatabaseMetaData objects created by getMetaData() to maximum 1 per connection */ | |
151 private DatabaseMetaData dbmd; | |
152 | |
150 | 153 |
151 /** | 154 /** |
152 * Constructor of a Connection for MonetDB. At this moment the | 155 * Constructor of a Connection for MonetDB. At this moment the |
153 * current implementation limits itself to storing the given host, | 156 * current implementation limits itself to storing the given host, |
154 * database, username and password for later use by the | 157 * database, username and password for later use by the |
584 * @throws SQLException if the current language is not SQL | 587 * @throws SQLException if the current language is not SQL |
585 * @return a DatabaseMetaData object for this Connection object | 588 * @return a DatabaseMetaData object for this Connection object |
586 */ | 589 */ |
587 @Override | 590 @Override |
588 public DatabaseMetaData getMetaData() throws SQLException { | 591 public DatabaseMetaData getMetaData() throws SQLException { |
592 // for debug: System.out.println("calling getMetaData()"); | |
589 if (lang != LANG_SQL) | 593 if (lang != LANG_SQL) |
590 throw new SQLException("This method is only supported in SQL mode", "M0M04"); | 594 throw new SQLException("This method is only supported in SQL mode", "M0M04"); |
591 | 595 if (dbmd == null) { |
592 return new MonetDatabaseMetaData(this); | 596 // first use, construct it once and reuse it for all next calls |
597 dbmd = new MonetDatabaseMetaData(this); | |
598 } | |
599 return dbmd; | |
593 } | 600 } |
594 | 601 |
595 /** | 602 /** |
596 * Retrieves this Connection object's current transaction isolation | 603 * Retrieves this Connection object's current transaction isolation |
597 * level. | 604 * level. |