DataSource: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 10: Line 10:
=Overview=
=Overview=


This page refers to a JSE [https://docs.oracle.com/javase/7/docs/api/javax/sql/DataSource.html javax.sql.DataSource]. The DataSource is part of [[JDBC]] and it is the main interface exposed by the <tt>javax.sql</tt> package. DataSource is part of JSE since 1.4. JDBC specifies that a database Connection can be obtained from a DriverManager or a DataSource. The DataSource is the preferred way of getting the Connection.
This page refers to a JSE [https://docs.oracle.com/javase/7/docs/api/javax/sql/DataSource.html javax.sql.DataSource]. The DataSource is part of [[JDBC]] and it is the main interface exposed by the <tt>javax.sql</tt> package. DataSource is part of JSE since 1.4. JDBC specifies that a database Connection can be obtained from a DriverManager or a DataSource. The DataSource is the preferred way of getting the Connection.
 
 
DataSources can be injected with the JEE [[@javax.annotation.Resource|@javax.annotation.Resource]] annotation.


=TODO=
=TODO=

Revision as of 14:36, 25 September 2017

External

Internal

Overview

This page refers to a JSE javax.sql.DataSource. The DataSource is part of JDBC and it is the main interface exposed by the javax.sql package. DataSource is part of JSE since 1.4. JDBC specifies that a database Connection can be obtained from a DriverManager or a DataSource. The DataSource is the preferred way of getting the Connection.

TODO

Organizatorium

According to JDBC Javadoc, a DataSource is a factory for connections to the physical data source that this DataSource object represents.

An object that implements the DataSource interface will typically be registered with a naming service based on the JavaTM Naming and Directory (JNDI) API.

Example: {{{

      DataSource ds = (DataSource)ic.lookup("java:/DefaultDS");
      Connection conn = ds.getConnection();
      ....
      conn.close();

}}}