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

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

org.netbeans.modules.db/0 1.20.0 4

org.netbeans.api.db.explorer
Class DatabaseConnection

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

public final class DatabaseConnection
extends Object

Encapsulates a database connection. Each DatabaseConnection instance represents a connection to a database in the Database Explorer.

This class provides access to the properties of a database connection, such as the connection name, database URL, user or default schema. New connections can be created using the create(org.netbeans.api.db.explorer.JDBCDriver, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean) method (these connections can be added to the Database Explorer using the ConnectionManager.addConnection(org.netbeans.api.db.explorer.DatabaseConnection) method.

It is also possible to retrieve the JDBC Connection using the getJDBCConnection() method (the connection can be connected or disconnected using the ConnectionManager.showConnectionDialog(org.netbeans.api.db.explorer.DatabaseConnection) and ConnectionManager.disconnect(org.netbeans.api.db.explorer.DatabaseConnection) methods.

See Also:
ConnectionManager

Method Summary
static DatabaseConnection create(JDBCDriver driver, String databaseURL, String user, String schema, String password, boolean rememberPassword)
          Creates a new DatabaseConnection instance.
 String getDatabaseURL()
          Returns this connection's database URL.
 String getDisplayName()
          Returns the name used to display this connection in the UI.
 String getDriverClass()
          Returns the JDBC driver class that this connection uses.
 Connection getJDBCConnection()
          Returns the Connection instance which encapsulates the physical connection to the database if this database connection is connected.
 String getName()
          Returns the programmatic name of this connection in the Database Explorer.
 String getPassword()
          Returns the password used to connect to the database.
 String getSchema()
          Returns this connection's default schema.
 String getUser()
          Returns the user name used to connect to the database.
 String toString()
          Returns a string representation of the database connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

create

public static DatabaseConnection create(JDBCDriver driver,
                                        String databaseURL,
                                        String user,
                                        String schema,
                                        String password,
                                        boolean rememberPassword)
Creates a new DatabaseConnection instance.

Parameters:
driver - the JDBC driver the new connection uses; cannot be null.
databaseURL - the URL of the database to connect to; cannot be null.
user - the username.
password - the password.
rememberPassword - whether to remeber the password for the current session.
Returns:
the new instance.
Throws:
NullPointerException - if driver or database are null.

getDriverClass

public String getDriverClass()
Returns the JDBC driver class that this connection uses.

Returns:
the JDBC driver class

getDatabaseURL

public String getDatabaseURL()
Returns this connection's database URL.

Returns:
the connection's database URL

getSchema

public String getSchema()
Returns this connection's default schema.

Returns:
the schema

getUser

public String getUser()
Returns the user name used to connect to the database.

Returns:
the user name

getPassword

public String getPassword()
Returns the password used to connect to the database.

Returns:
the password

getName

public String getName()
Returns the programmatic name of this connection in the Database Explorer.

Returns:
the programmatic name

getDisplayName

public String getDisplayName()
Returns the name used to display this connection in the UI.

Returns:
the display name

getJDBCConnection

public Connection getJDBCConnection()
Returns the Connection instance which encapsulates the physical connection to the database if this database connection is connected. Note that "connected" here means "connected using the Database Explorer". There is no check if Connection.close() has been called on the returned connection. However, clients should not call Connection.close() on the returned connection, therefore this method should always return a non-closed connection or null.

Calling Connection.close() on the connection returned by this method is illegal. Use ConnectionManager.disconnect(org.netbeans.api.db.explorer.DatabaseConnection) to close the connection.

Returns:
the physical connection or null if not connected.
Throws:
IllegalStateException - if this connection is not added to the ConnectionManager.

toString

public String toString()
Returns a string representation of the database connection.

Overrides:
toString in class Object

org.netbeans.modules.db/0 1.20.0 4

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