Skip to content

Commit

Permalink
* 更新实现
Browse files Browse the repository at this point in the history
  • Loading branch information
fjn committed Dec 27, 2020
1 parent b525771 commit 11a9768
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
package com.jn.sqlhelper.datasource.driver;


import com.jn.sqlhelper.datasource.AbstractDataSource;
import com.jn.sqlhelper.datasource.driver.DriverManagerDataSource;
import com.jn.sqlhelper.datasource.driver.SimpleDriverDataSource;
import com.jn.langx.util.Preconditions;
import com.jn.sqlhelper.datasource.AbstractDataSource;

import java.sql.Connection;
import java.sql.SQLException;
Expand All @@ -28,9 +26,9 @@
* Abstract base class for JDBC {@link javax.sql.DataSource} implementations
* that operate on a JDBC {@link java.sql.Driver}.
*
* @since 2.3.0
* @see SimpleDriverDataSource
* @see DriverManagerDataSource
* @since 3.4.0
*/
public abstract class AbstractDriverBasedDataSource extends AbstractDataSource {

Expand All @@ -49,6 +47,7 @@ public abstract class AbstractDriverBasedDataSource extends AbstractDataSource {

/**
* Set the JDBC URL to use for connecting through the Driver.
*
* @see java.sql.Driver#connect(String, java.util.Properties)
*/
public void setUrl(String url) {
Expand All @@ -65,6 +64,7 @@ public String getUrl() {

/**
* Set the JDBC username to use for connecting through the Driver.
*
* @see java.sql.Driver#connect(String, java.util.Properties)
*/
public void setUsername(String username) {
Expand All @@ -80,6 +80,7 @@ public String getUsername() {

/**
* Set the JDBC password to use for connecting through the Driver.
*
* @see java.sql.Driver#connect(String, java.util.Properties)
*/
public void setPassword(String password) {
Expand All @@ -95,15 +96,17 @@ public String getPassword() {

/**
* Specify a database catalog to be applied to each Connection.
* @since 2.3.0
*
* @see Connection#setCatalog
* @since 2.3.0
*/
public void setCatalog(String catalog) {
this.catalog = catalog;
}

/**
* Return the database catalog to be applied to each Connection, if any.
*
* @since 2.3.0
*/
public String getCatalog() {
Expand All @@ -112,6 +115,7 @@ public String getCatalog() {

/**
* Specify a database schema to be applied to each Connection.
*
* @since 2.3.0
*/
public void setSchema(String schema) {
Expand All @@ -131,6 +135,7 @@ public String getSchema() {
* <p>Can also contain "user" and "password" properties. However,
* any "username" and "password" bean properties specified on this
* DataSource will override the corresponding connection properties.
*
* @see java.sql.Driver#connect(String, java.util.Properties)
*/
public void setConnectionProperties(Properties connectionProperties) {
Expand All @@ -148,6 +153,7 @@ public Properties getConnectionProperties() {
/**
* This implementation delegates to {@code getConnectionFromDriver},
* using the default username and password of this DataSource.
*
* @see #getConnectionFromDriver(String, String)
* @see #setUsername
* @see #setPassword
Expand All @@ -160,6 +166,7 @@ public Connection getConnection() throws SQLException {
/**
* This implementation delegates to {@code getConnectionFromDriver},
* using the given username and password.
*
* @see #getConnectionFromDriver(String, String)
*/
@Override
Expand All @@ -171,6 +178,7 @@ public Connection getConnection(String username, String password) throws SQLExce
/**
* Build properties for the Driver, including the given username and password (if any),
* and obtain a corresponding Connection.
*
* @param username the name of the user
* @param password the password to use
* @return the obtained Connection
Expand Down Expand Up @@ -203,6 +211,7 @@ protected Connection getConnectionFromDriver(String username, String password) t
/**
* Obtain a Connection using the given properties.
* <p>Template method to be implemented by subclasses.
*
* @param props the merged connection properties
* @return the obtained Connection
* @throws SQLException in case of failure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
* connection pool beans, supporting the same basic properties as this class
* plus specific settings (such as minimal/maximal pool size etc).
*
* @author Juergen Hoeller
* @since 2.5.5
* @see DriverManagerDataSource
*/
public class SimpleDriverDataSource extends AbstractDriverBasedDataSource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
* In contrast to {@link com.jn.sqlhelper.datasource.driver.DriverManagerDataSource}, it reuses the same Connection
* all the time, avoiding excessive creation of physical Connections.
*
* @author Rod Johnson
* @author Juergen Hoeller
* @see #getConnection()
* @see java.sql.Connection#close()
*/
Expand Down

0 comments on commit 11a9768

Please sign in to comment.