Javax. SQL. datasource Interface

Source: Internet
Author: User
Javax. SQL
Interface datasource
public interface DataSource

 

This factory is used to provideDataSourceObject. AsDriverManagerReplacement of facilities,DataSourceObject is the preferred method to obtain connections. ImplementationDataSourceInterface objects are generally registered in the Naming Service Based on the javatm naming and Directory Interface (JNDI) API.

DataSourceThe interface is implemented by the driver supplier. There are three types of implementations:

  1. Basic implementation-generate standardsConnectionObject
  2. Connection Pool implementation-generate automatically participate in connection poolConnectionObject. This implementation is used with the connection pool manager of the intermediate layer.
  3. Distributed Transaction implementation-generateConnectionObject, which can be used for distributed transactions and is almost always involved in the connection pool. This implementation is used with the Transaction Manager in the middle layer and almost always used with the connection pool manager.

DataSourceThe attributes of an object can be modified as needed. For example, if you move a data source to another server, you can change the server-related attributes. The advantage is that any code accessing the data source does not need to be changed because the attribute of the data source can be changed.

PassDataSourceThe driver accessed by the object does notDriverManagerRegister. Search by search operationDataSourceObject, and then use this object to createConnectionObject. Using basic implementationDataSourceConnection and passDriverManagerThe connection obtained by the facility is the same.

 

 

Start with the following versions:
1.4

Method Summary
 Connection getConnection()
Try to establishDataSourceObject.
 Connection getConnection(String username, String password)
Try to establishDataSourceObject.
 int getLoginTimeout()
Obtain the maximum wait time for the data source to connect to a database, in seconds.
 PrintWriter getLogWriter()
Retrieve thisDataSourceObject log writer.
 void setLoginTimeout(int seconds)
Sets the maximum wait time, in seconds, when the data source tries to connect to a database.
 void setLogWriter(PrintWriter out)
Set thisDataSourceSet the object's log writer to a givenjava.io.PrintWriterObject.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.