Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,21 +23,22 @@ import java.sql.SQLException;
|
||||
import org.springframework.jdbc.support.JdbcUtils;
|
||||
|
||||
/**
|
||||
* Implementation of RowCallbackHandler. Convenient superclass for callback handlers.
|
||||
* An instance can only be used once.
|
||||
* Implementation of {@link RowCallbackHandler}. An instance can only be used once.
|
||||
*
|
||||
* <p>We can either use this on its own (for example, in a test case, to ensure
|
||||
* that our result sets have valid dimensions), or use it as a superclass
|
||||
* for callback handlers that actually do something, and will benefit
|
||||
* from the dimension information it provides.
|
||||
* that our result sets have valid dimensions), or use it as a superclass for
|
||||
* callback handlers that actually do something, and will benefit from the
|
||||
* dimension information it provides.
|
||||
*
|
||||
* <p>A usage example with JdbcTemplate:
|
||||
* <p>A usage example with {@link JdbcTemplate}:
|
||||
*
|
||||
* <pre class="code">JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); // reusable object
|
||||
* <pre class="code">
|
||||
* JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); // reusable object
|
||||
*
|
||||
* RowCountCallbackHandler countCallback = new RowCountCallbackHandler(); // not reusable
|
||||
* jdbcTemplate.query("select * from user", countCallback);
|
||||
* int rowCount = countCallback.getRowCount();</pre>
|
||||
* int rowCount = countCallback.getRowCount();
|
||||
* </pre>
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @since May 3, 2001
|
||||
@@ -63,7 +64,6 @@ public class RowCountCallbackHandler implements RowCallbackHandler {
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of ResultSetCallbackHandler.
|
||||
* Work out column size if this is the first row, otherwise just count rows.
|
||||
* <p>Subclasses can perform custom extraction or processing
|
||||
* by overriding the {@code processRow(ResultSet, int)} method.
|
||||
@@ -103,7 +103,7 @@ public class RowCountCallbackHandler implements RowCallbackHandler {
|
||||
* <b>Indexed from 0 to n-1.</b>
|
||||
*/
|
||||
public final int[] getColumnTypes() {
|
||||
return columnTypes;
|
||||
return this.columnTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +113,7 @@ public class RowCountCallbackHandler implements RowCallbackHandler {
|
||||
* <b>Indexed from 0 to n-1.</b>
|
||||
*/
|
||||
public final String[] getColumnNames() {
|
||||
return columnNames;
|
||||
return this.columnNames;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +122,7 @@ public class RowCountCallbackHandler implements RowCallbackHandler {
|
||||
* @return the number of rows in this ResultSet
|
||||
*/
|
||||
public final int getRowCount() {
|
||||
return rowCount;
|
||||
return this.rowCount;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +132,7 @@ public class RowCountCallbackHandler implements RowCallbackHandler {
|
||||
* @return the number of columns in this result set
|
||||
*/
|
||||
public final int getColumnCount() {
|
||||
return columnCount;
|
||||
return this.columnCount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,13 +47,13 @@ public class TableMetaDataContext {
|
||||
/** Logger available to subclasses */
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
/** name of table for this context **/
|
||||
/** Name of table for this context */
|
||||
private String tableName;
|
||||
|
||||
/** name of catalog for this context **/
|
||||
/** Name of catalog for this context */
|
||||
private String catalogName;
|
||||
|
||||
/** name of schema for this context **/
|
||||
/** Name of schema for this context */
|
||||
private String schemaName;
|
||||
|
||||
/** List of columns objects to be used in this context */
|
||||
@@ -153,40 +153,6 @@ public class TableMetaDataContext {
|
||||
return this.tableColumns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this database support the JDBC 3.0 feature of retrieving generated keys
|
||||
* {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}?
|
||||
*/
|
||||
public boolean isGetGeneratedKeysSupported() {
|
||||
return this.metaDataProvider.isGetGeneratedKeysSupported();
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this database support simple query to retrieve generated keys
|
||||
* when the JDBC 3.0 feature is not supported.
|
||||
* {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}?
|
||||
*/
|
||||
public boolean isGetGeneratedKeysSimulated() {
|
||||
return this.metaDataProvider.isGetGeneratedKeysSimulated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this database support simple query to retrieve generated keys
|
||||
* when the JDBC 3.0 feature is not supported.
|
||||
* {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}?
|
||||
*/
|
||||
public String getSimulationQueryForGetGeneratedKey(String tableName, String keyColumnName) {
|
||||
return this.metaDataProvider.getSimpleQueryForGetGeneratedKey(tableName, keyColumnName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a column name String array for retrieving generated keys supported?
|
||||
* {@link java.sql.Connection#createStruct(String, Object[])}?
|
||||
*/
|
||||
public boolean isGeneratedKeysColumnNameArraySupported() {
|
||||
return this.metaDataProvider.isGeneratedKeysColumnNameArraySupported();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set {@link NativeJdbcExtractor} to be used to retrieve the native connection.
|
||||
*/
|
||||
@@ -224,7 +190,7 @@ public class TableMetaDataContext {
|
||||
keys.add(key.toUpperCase());
|
||||
}
|
||||
List<String> columns = new ArrayList<String>();
|
||||
for (TableParameterMetaData meta : metaDataProvider.getTableParameterMetaData()) {
|
||||
for (TableParameterMetaData meta : this.metaDataProvider.getTableParameterMetaData()) {
|
||||
if (!keys.contains(meta.getParameterName().toUpperCase())) {
|
||||
columns.add(meta.getParameterName());
|
||||
}
|
||||
@@ -368,4 +334,39 @@ public class TableMetaDataContext {
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Does this database support the JDBC 3.0 feature of retrieving generated keys
|
||||
* {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}?
|
||||
*/
|
||||
public boolean isGetGeneratedKeysSupported() {
|
||||
return this.metaDataProvider.isGetGeneratedKeysSupported();
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this database support simple query to retrieve generated keys
|
||||
* when the JDBC 3.0 feature is not supported.
|
||||
* {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}?
|
||||
*/
|
||||
public boolean isGetGeneratedKeysSimulated() {
|
||||
return this.metaDataProvider.isGetGeneratedKeysSimulated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this database support simple query to retrieve generated keys
|
||||
* when the JDBC 3.0 feature is not supported.
|
||||
* {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}?
|
||||
*/
|
||||
public String getSimulationQueryForGetGeneratedKey(String tableName, String keyColumnName) {
|
||||
return this.metaDataProvider.getSimpleQueryForGetGeneratedKey(tableName, keyColumnName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a column name String array for retrieving generated keys supported?
|
||||
* {@link java.sql.Connection#createStruct(String, Object[])}?
|
||||
*/
|
||||
public boolean isGeneratedKeysColumnNameArraySupported() {
|
||||
return this.metaDataProvider.isGeneratedKeysColumnNameArraySupported();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,12 +34,12 @@ import org.springframework.util.Assert;
|
||||
* connection pool, implementing the same standard interface, but creating new
|
||||
* Connections on every call.
|
||||
*
|
||||
* <p>In a J2EE container, it is recommended to use a JNDI DataSource provided by
|
||||
* <p>In a Java EE container, it is recommended to use a JNDI DataSource provided by
|
||||
* the container. Such a DataSource can be exposed as a DataSource bean in a Spring
|
||||
* ApplicationContext via {@link org.springframework.jndi.JndiObjectFactoryBean},
|
||||
* for seamless switching to and from a local DataSource bean like this class.
|
||||
*
|
||||
* <p>If you need a "real" connection pool outside of a J2EE container, consider
|
||||
* <p>If you need a "real" connection pool outside of a Java EE container, consider
|
||||
* <a href="http://commons.apache.org/proper/commons-dbcp">Apache Commons DBCP</a>
|
||||
* or <a href="http://sourceforge.net/projects/c3p0">C3P0</a>.
|
||||
* Commons DBCP's BasicDataSource and C3P0's ComboPooledDataSource are full
|
||||
|
||||
Reference in New Issue
Block a user