This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 192150
Collapse All | Expand All

(-)a/db/apichanges.xml (-1 / +16 lines)
Lines 30-36 Link Here
30
Contributor(s):
30
Contributor(s):
31
31
32
The Original Software is NetBeans. The Initial Developer of the Original
32
The Original Software is NetBeans. The Initial Developer of the Original
33
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
33
Software is Sun Microsystems, Inc. Portions Copyright 1997-2010 Sun
34
Microsystems, Inc. All Rights Reserved.
34
Microsystems, Inc. All Rights Reserved.
35
35
36
If you wish your version of this file to be governed by only the CDDL
36
If you wish your version of this file to be governed by only the CDDL
Lines 110-115 Link Here
110
    <changes>
110
    <changes>
111
        <change>
111
        <change>
112
            <api name="database_explorer_api"/>
112
            <api name="database_explorer_api"/>
113
            <summary>Allow specify display name of the DatabaseConnection</summary>
114
            <version major="1" minor="42"/>
115
            <date day="22" month="11" year="2010"/>
116
            <author login="jrechtacek"/>
117
            <compatibility addition="yes"/>
118
            <description>
119
                Allow to specify the display name of the connection as it shows
120
                under the Databases node. Added new factory method to create
121
                database connection with given display name.
122
            </description>
123
            <class package="org.netbeans.api.db.explorer" name="DatabaseConnection"/>
124
            <issue number="192150"/>
125
        </change>
126
        <change>
127
            <api name="database_explorer_api"/>
113
            <summary>Add a DatabaseConnection.getJDBCDriver() method</summary>
128
            <summary>Add a DatabaseConnection.getJDBCDriver() method</summary>
114
            <version major="1" minor="32"/>
129
            <version major="1" minor="32"/>
115
            <date day="6" month="5" year="2009"/>
130
            <date day="6" month="5" year="2009"/>
(-)a/db/nbproject/project.properties (-1 / +1 lines)
Lines 45-51 Link Here
45
javadoc.arch=${basedir}/arch.xml
45
javadoc.arch=${basedir}/arch.xml
46
javadoc.apichanges=${basedir}/apichanges.xml
46
javadoc.apichanges=${basedir}/apichanges.xml
47
47
48
spec.version.base=1.41.0
48
spec.version.base=1.42.0
49
49
50
extra.module.files=modules/ext/ddl.jar
50
extra.module.files=modules/ext/ddl.jar
51
51
(-)a/db/src/org/netbeans/api/db/explorer/DatabaseConnection.java (-3 / +26 lines)
Lines 27-33 Link Here
27
 * Contributor(s):
27
 * Contributor(s):
28
 *
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2009 Sun
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2010 Sun
31
 * Microsystems, Inc. All Rights Reserved.
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
33
 * If you wish your version of this file to be governed by only the CDDL
Lines 87-92 Link Here
87
    
87
    
88
    static {
88
    static {
89
        DatabaseConnectionAccessor.DEFAULT = new DatabaseConnectionAccessor() {
89
        DatabaseConnectionAccessor.DEFAULT = new DatabaseConnectionAccessor() {
90
            @Override
90
            public DatabaseConnection createDatabaseConnection(org.netbeans.modules.db.explorer.DatabaseConnection conn) {
91
            public DatabaseConnection createDatabaseConnection(org.netbeans.modules.db.explorer.DatabaseConnection conn) {
91
                return new DatabaseConnection(conn);
92
                return new DatabaseConnection(conn);
92
            }    
93
            }    
Lines 109-115 Link Here
109
    }
110
    }
110
    
111
    
111
    /**
112
    /**
112
     * Creates a new DatabaseConnection instance. 
113
     * Creates a new DatabaseConnection instance w/ a default display name based
114
     * on connection URL and user
113
     * 
115
     * 
114
     * @param driver the JDBC driver the new connection uses; cannot be null.
116
     * @param driver the JDBC driver the new connection uses; cannot be null.
115
     * @param databaseURL the URL of the database to connect to; cannot be null.
117
     * @param databaseURL the URL of the database to connect to; cannot be null.
Lines 124-129 Link Here
124
     */
126
     */
125
    public static DatabaseConnection create(JDBCDriver driver, String databaseURL, 
127
    public static DatabaseConnection create(JDBCDriver driver, String databaseURL, 
126
            String user, String schema, String password, boolean rememberPassword) {
128
            String user, String schema, String password, boolean rememberPassword) {
129
            return create(driver, databaseURL, user, schema, password, rememberPassword, null);
130
    }
131
132
    /**
133
     * Creates a new DatabaseConnection instance.
134
     *
135
     * @param driver the JDBC driver the new connection uses; cannot be null.
136
     * @param databaseURL the URL of the database to connect to; cannot be null.
137
     * @param user the username.
138
     * @param schema the schema to use, or null for the default schema
139
     * @param password the password.
140
     * @param rememberPassword whether to remember the password for the current session.
141
     * @param displayName the display name of the connection as it shows under the Databases node
142
     *
143
     * @return the new instance.
144
     *
145
     * @throws NullPointerException if driver or database are null.
146
     */
147
    public static DatabaseConnection create(JDBCDriver driver, String databaseURL, 
148
            String user, String schema, String password, boolean rememberPassword,
149
            String displayName) {
127
        if (driver == null || databaseURL == null) {
150
        if (driver == null || databaseURL == null) {
128
            throw new NullPointerException();
151
            throw new NullPointerException();
129
        }
152
        }
Lines 135-141 Link Here
135
        conn.setSchema(schema);
158
        conn.setSchema(schema);
136
        conn.setPassword(password);
159
        conn.setPassword(password);
137
        conn.setRememberPassword(rememberPassword);
160
        conn.setRememberPassword(rememberPassword);
138
        
161
        conn.setDisplayName(displayName);
139
        return conn.getDatabaseConnection();
162
        return conn.getDatabaseConnection();
140
    }
163
    }
141
    
164
    
(-)a/db/test/unit/src/org/netbeans/api/db/explorer/DatabaseConnectionTest.java (-1 / +37 lines)
Lines 27-33 Link Here
27
 * Contributor(s):
27
 * Contributor(s):
28
 *
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2009 Sun
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2010 Sun
31
 * Microsystems, Inc. All Rights Reserved.
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
33
 * If you wish your version of this file to be governed by only the CDDL
Lines 195-200 Link Here
195
        }
195
        }
196
    }
196
    }
197
197
198
    /**
199
     * Verifies that the {@link DatabaseConnection#create(org.netbeans.api.db.explorer.JDBCDriver, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean, java.lang.String)}
200
     * factory method creates a valid connection with the given display name
201
     *
202
     * @throws Exception
203
     */
204
    public void testDatabaseConnectionCreatedWithDisplayName() throws Exception {
205
        Util.clearConnections();
206
        Util.deleteDriverFiles();
207
208
        JDBCDriver driver = Util.createDummyDriver();
209
        DatabaseConnection dbconn = DatabaseConnection.create(driver, "database", "user", "schema", "password", true, "displayName");
210
211
        assertEquals("The connection was created with a display name different that the one provided", "displayName", dbconn.getDisplayName());
212
213
        Util.clearConnections();
214
215
    }
216
217
    /**
218
     * Verifies that the {@link DatabaseConnection#create(org.netbeans.api.db.explorer.JDBCDriver, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean)}
219
     * creates some default display name that is not null
220
     * @throws Exception
221
     */
222
    public void testDatabaseConnectionCreatedWithDefaultDisplayName() throws Exception {
223
        Util.clearConnections();
224
        Util.deleteDriverFiles();
225
226
        JDBCDriver driver = Util.createDummyDriver();
227
        DatabaseConnection dbconn = DatabaseConnection.create(driver, "database", "user", "schema", "password", true);
228
229
        assertEquals("The connection was created with the default display name ", "database [user on schema]", dbconn.getDisplayName());
230
231
        Util.clearConnections();
232
    }
233
198
    private static boolean connectionIsValid(Connection conn) throws Exception {
234
    private static boolean connectionIsValid(Connection conn) throws Exception {
199
        return org.netbeans.modules.db.explorer.DatabaseConnection.isVitalConnection(conn, null);
235
        return org.netbeans.modules.db.explorer.DatabaseConnection.isVitalConnection(conn, null);
200
    }
236
    }

Return to bug 192150