站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

ConnectionManager (Database Explorer) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.db/0 1.20.0 4

org.netbeans.api.db.explorer
Class ConnectionManager

java.lang.Object
  extended by org.netbeans.api.db.explorer.ConnectionManager

public final class ConnectionManager
extends Object

Provides access to the list of connections in the Database Explorer.

The list of connections can be retrieved using the getConnections() method. A connection can be also retrieved by name using the getConnection(java.lang.String) method.

New connections can be added to the Connection Manager using the addConnection(org.netbeans.api.db.explorer.DatabaseConnection) method (new connections can be created using the DatabaseConnection.create(org.netbeans.api.db.explorer.JDBCDriver, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean) method. It is also possible to display the New Database Connection dialog to let the user create a new database connection using the showAddConnectionDialog(org.netbeans.api.db.explorer.JDBCDriver). Connections can be realized using the showConnectionDialog(org.netbeans.api.db.explorer.DatabaseConnection) method.

Clients can be informed of changes to the ConnectionManager by registering a ConnectionListener using the addConnectionListener(org.netbeans.api.db.explorer.ConnectionListener) method.

See Also:
DatabaseConnection

Constructor Summary
ConnectionManager()
           
 
Method Summary
 void addConnection(DatabaseConnection dbconn)
          Adds a new connection to Database Explorer.
 void addConnectionListener(ConnectionListener listener)
          Registers a ConnectionListener.
 void disconnect(DatabaseConnection dbconn)
          Disconnects this connection from the database.
 DatabaseConnection getConnection(String name)
          Returns the connection with the specified name.
 DatabaseConnection[] getConnections()
          Returns the list of connections in the Database Explorer.
static ConnectionManager getDefault()
          Gets the ConnectionManager singleton instance.
 void removeConnectionListener(ConnectionListener listener)
          Unregisters the specified connection listener.
 void selectConnectionInExplorer(DatabaseConnection dbconn)
          Selects the node corresponding to the specified connection in the Runtime tab.
 void showAddConnectionDialog(JDBCDriver driver)
          Shows the dialog for adding a new connection.
 void showAddConnectionDialog(JDBCDriver driver, String databaseUrl)
          Shows the dialog for adding a new connection with the specified database URL.
 void showAddConnectionDialog(JDBCDriver driver, String databaseUrl, String user, String password)
          Shows the dialog for adding a new connection with the specified database URL, user and password The specified driver be filled as the single element of the Driver combo box of the New Database Connection dialog box.
 DatabaseConnection showAddConnectionDialogFromEventThread(JDBCDriver driver)
          The counterpart of showAddConnectionDialog(JDBCDriver) which returns the newly created database connection, but must be called from the event dispatching thread.
 DatabaseConnection showAddConnectionDialogFromEventThread(JDBCDriver driver, String databaseUrl)
          The counterpart of showAddConnectionDialog(JDBCDriver, String) which returns the newly created database connection, but must be called from the event dispatching thread.
 DatabaseConnection showAddConnectionDialogFromEventThread(JDBCDriver driver, String databaseUrl, String user, String password)
          The counterpart of showAddConnectionDialog(JDBCDriver, String, String, String) which returns the newly created database connection, but must be called from the event dispatching thread.
 void showConnectionDialog(DatabaseConnection dbconn)
          Shows the Connect dialog for the specified connection if not all data needed to connect, such as the user name or password, are known), or displays a modal progress dialog and attempts to connect to the database immediately.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionManager

public ConnectionManager()
Method Detail

getDefault

public static ConnectionManager getDefault()
Gets the ConnectionManager singleton instance.


getConnections

public DatabaseConnection[] getConnections()
Returns the list of connections in the Database Explorer.

Returns:
a non-null array of connections.

getConnection

public DatabaseConnection getConnection(String name)
Returns the connection with the specified name.

Parameters:
name - the connection name
Throws:
NullPointerException - if the specified database name is null.

addConnection

public void addConnection(DatabaseConnection dbconn)
                   throws DatabaseException
Adds a new connection to Database Explorer. This method does not display any UI and does not try to connect to the respective database.

Parameters:
dbconn - the connection to be added; must not be null.
Throws:
NullPointerException - if dbconn is null.
DatabaseException - if an error occurs while adding the connection.

showAddConnectionDialog

public void showAddConnectionDialog(JDBCDriver driver)
Shows the dialog for adding a new connection. The specified driver will be selected by default in the New Database Connection dialog.

Parameters:
driver - the JDBC driver; can be null.

showAddConnectionDialog

public void showAddConnectionDialog(JDBCDriver driver,
                                    String databaseUrl)
Shows the dialog for adding a new connection with the specified database URL. The specified driver be filled as the single element of the Driver combo box of the New Database Connection dialog box. The database URL will be filled in the Database URL field in the New Database Connection dialog box.

Parameters:
driver - the JDBC driver; can be null.
databaseUrl - the database URL; can be null.

showAddConnectionDialog

public void showAddConnectionDialog(JDBCDriver driver,
                                    String databaseUrl,
                                    String user,
                                    String password)
Shows the dialog for adding a new connection with the specified database URL, user and password The specified driver be filled as the single element of the Driver combo box of the New Database Connection dialog box. The database URL will be filled in the Database URL field in the New Database Connection dialog box. The user and password will be filled in the User Name and Password fields in the New Database Connection dialog box.

Parameters:
driver - the JDBC driver; can be null.
databaseUrl - the database URL; can be null.
user - the database user; can be null.
password - user's password; can be null.
Since:
1.19

showAddConnectionDialogFromEventThread

public DatabaseConnection showAddConnectionDialogFromEventThread(JDBCDriver driver)
The counterpart of showAddConnectionDialog(JDBCDriver) which returns the newly created database connection, but must be called from the event dispatching thread.

Parameters:
driver - the JDBC driver; can be null.
Returns:
the new database connection or null if no database connection was created (e.g. the user pressed Cancel).
Throws:
IllegalStateException - if the calling thread is not the event dispatching thread.
Since:
1.19

showAddConnectionDialogFromEventThread

public DatabaseConnection showAddConnectionDialogFromEventThread(JDBCDriver driver,
                                                                 String databaseUrl)
The counterpart of showAddConnectionDialog(JDBCDriver, String) which returns the newly created database connection, but must be called from the event dispatching thread.

Parameters:
driver - the JDBC driver; can be null.
databaseUrl - the database URL; can be null.
Returns:
the new database connection or null if no database connection was created (e.g. the user pressed Cancel).
Throws:
IllegalStateException - if the calling thread is not the event dispatching thread.
Since:
1.19

showAddConnectionDialogFromEventThread

public DatabaseConnection showAddConnectionDialogFromEventThread(JDBCDriver driver,
                                                                 String databaseUrl,
                                                                 String user,
                                                                 String password)
The counterpart of showAddConnectionDialog(JDBCDriver, String, String, String) which returns the newly created database connection, but must be called from the event dispatching thread.

Parameters:
driver - the JDBC driver; can be null.
databaseUrl - the database URL; can be null.
user - the database user; can be null.
password - user's password; can be null.
Returns:
the new database connection or null if no database connection was created (e.g. the user pressed Cancel).
Throws:
IllegalStateException - if the calling thread is not the event dispatching thread.
Since:
1.19

showConnectionDialog

public void showConnectionDialog(DatabaseConnection dbconn)
Shows the Connect dialog for the specified connection if not all data needed to connect, such as the user name or password, are known), or displays a modal progress dialog and attempts to connect to the database immediately.

Parameters:
dbconn - the database connection to be connected
Throws:
NullPointerException - if the dbconn parameter is null
IllegalStateException - if this connection is not added to the ConnectionManager.

disconnect

public void disconnect(DatabaseConnection dbconn)
Disconnects this connection from the database. Does not do anything if not connected.

Parameters:
dbconn - the database connection to be connected
Throws:
NullPointerException - if the dbconn parameter is null
IllegalStateException - if this connection is not added to the ConnectionManager.

selectConnectionInExplorer

public void selectConnectionInExplorer(DatabaseConnection dbconn)
Selects the node corresponding to the specified connection in the Runtime tab.

Parameters:
dbconn - the connection to select
Throws:
NullPointerException - if the dbconn parameter is null
IllegalStateException - if this connection is not added to the ConnectionManager.

addConnectionListener

public void addConnectionListener(ConnectionListener listener)
Registers a ConnectionListener.


removeConnectionListener

public void removeConnectionListener(ConnectionListener listener)
Unregisters the specified connection listener.


org.netbeans.modules.db/0 1.20.0 4

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.