Class JNDIConnector

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, Connector

    public class JNDIConnector
    extends java.lang.Object
    implements Connector
    Specifies the J2EE DataSource lookup options. This connector is normally used with a login in a J2EE environment to connect to a server's connection pool defined by the DataSource name. The JNDI name that the DataSource is registered under must be specified, this must include any required prefix such as "java:comp/env/", (unless a DataSource object is given). A Context is only required if not running on the server, otherwise default to a new InitialContext().
    See Also:
    Serialized Form
    Author:
    Big Country
    Since:
    TOPLink/Java 2.1
    • Constructor Summary

      Constructors 
      Constructor Description
      JNDIConnector()
      PUBLIC: Construct a Connector with no settings.
      JNDIConnector​(java.lang.String name)
      PUBLIC: Construct a Connector with the datasource name.
      JNDIConnector​(javax.naming.Context context, java.lang.String name)
      PUBLIC: Construct a Connector with the datasource name.
      JNDIConnector​(javax.sql.DataSource dataSource)
      PUBLIC: Construct a Connector with the datasource object.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      java.lang.Object clone()
      INTERNAL: Clone the connector.
      java.sql.Connection connect​(java.util.Properties properties, Session session)
      INTERNAL: Connect with the specified properties and return the Connection.
      java.lang.String getConnectionDetails()
      PUBLIC: Provide the details of my connection information.
      javax.naming.Context getContext()
      PUBLIC: Return the JNDI Context that can supplied the named DataSource.
      javax.sql.DataSource getDataSource()
      PUBLIC: Return the javax.sql.DataSource.
      int getLookupType()
      Deprecated.
      As of 2.6.0, replaced by configuration provided by ServerPlatform.getJNDIConnectorLookupType()
      java.lang.String getName()
      PUBLIC: Return the name of the DataSource within the JNDI Context.
      void setContext​(javax.naming.Context context)
      PUBLIC: Set the JNDI Context that can supply the named DataSource.
      void setDataSource​(javax.sql.DataSource dataSource)
      PUBLIC: Set the javax.sql.DataSource.
      void setLookupType​(int lookupType)
      Deprecated.
      As of 2.6.0, replaced by configuration provided by ServerPlatform.getJNDIConnectorLookupType()
      void setName​(java.lang.String name)
      PUBLIC: Set the name of the DataSource within the JNDI Context.
      java.lang.String toString()
      PUBLIC: Print data source info.
      void toString​(java.io.PrintWriter writer)
      INTERNAL: Print something useful on the log.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • dataSource

        protected javax.sql.DataSource dataSource
      • context

        protected javax.naming.Context context
      • name

        protected java.lang.String name
      • isCallbackRegistered

        protected boolean isCallbackRegistered
      • lookupType

        @Deprecated
        protected int lookupType
        Deprecated.
    • Constructor Detail

      • JNDIConnector

        public JNDIConnector()
        PUBLIC: Construct a Connector with no settings. The datasource name will still need to be set.
      • JNDIConnector

        public JNDIConnector​(javax.naming.Context context,
                             java.lang.String name)
                      throws ValidationException
        PUBLIC: Construct a Connector with the datasource name.
        Throws:
        ValidationException
      • JNDIConnector

        public JNDIConnector​(java.lang.String name)
        PUBLIC: Construct a Connector with the datasource name.
      • JNDIConnector

        public JNDIConnector​(javax.sql.DataSource dataSource)
        PUBLIC: Construct a Connector with the datasource object.
    • Method Detail

      • clone

        public java.lang.Object clone()
        INTERNAL: Clone the connector.
        Specified by:
        clone in interface Connector
        Overrides:
        clone in class java.lang.Object
      • getContext

        public javax.naming.Context getContext()
        PUBLIC: Return the JNDI Context that can supplied the named DataSource.
      • getDataSource

        public javax.sql.DataSource getDataSource()
        PUBLIC: Return the javax.sql.DataSource.
      • getName

        public java.lang.String getName()
        PUBLIC: Return the name of the DataSource within the JNDI Context.
      • getConnectionDetails

        public java.lang.String getConnectionDetails()
        PUBLIC: Provide the details of my connection information. This is primarily for JMX runtime services.
        Specified by:
        getConnectionDetails in interface Connector
        Returns:
        java.lang.String
      • setContext

        public void setContext​(javax.naming.Context context)
        PUBLIC: Set the JNDI Context that can supply the named DataSource.
      • setDataSource

        public void setDataSource​(javax.sql.DataSource dataSource)
        PUBLIC: Set the javax.sql.DataSource.
      • toString

        public java.lang.String toString()
        PUBLIC: Print data source info.
        Overrides:
        toString in class java.lang.Object
      • toString

        public void toString​(java.io.PrintWriter writer)
        INTERNAL: Print something useful on the log.
        Specified by:
        toString in interface Connector