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.

Bug 197408 - Enable editting of connection properties for db connections
Summary: Enable editting of connection properties for db connections
Status: RESOLVED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.0.1
Hardware: PC Linux
: P3 normal (vote)
Assignee: Jaroslav Havlin
URL:
Keywords: API, API_REVIEW_FAST, NETFIX
Depends on:
Blocks:
 
Reported: 2011-04-04 18:38 UTC by matthias42
Modified: 2013-02-23 04:08 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Please see report text (44.12 KB, patch)
2011-04-04 18:38 UTC, matthias42
Details | Diff
Revised patch (41.84 KB, patch)
2011-05-27 17:07 UTC, matthias42
Details | Diff
Proposed Patch v3 (41.03 KB, patch)
2013-02-12 15:44 UTC, Jaroslav Havlin
Details | Diff
proposed patch v4 (60.84 KB, patch)
2013-02-12 20:45 UTC, matthias42
Details | Diff
Proposed Patch v5 (62.59 KB, patch)
2013-02-13 10:40 UTC, Jaroslav Havlin
Details | Diff
Proposed Patch v6 (67.74 KB, patch)
2013-02-13 14:55 UTC, Jaroslav Havlin
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description matthias42 2011-04-04 18:38:42 UTC
Created attachment 107484 [details]
Please see report text

Hey,

as asked on the nbusers-mailinglist (http://forums.netbeans.org/topic37742.html) and following some frustrations with regard to very long JDBC-URLs (ever tried to put all the possible Informix properties into the URL or use mysql connector/j with a ssh-connector?), there seems to be some need for the ability to set the connection properties.

I had some look at the code and prepared a patch to add this ability. It's tested against my test-informix installation. So please have a look at it.

Thanks in advance

Matthias

PS: Yes I know that the properties are not integrated into the new connection wizard, but then - this can be added (if wished) or ignored, as this is an advanced feature.
Comment 1 matthias42 2011-05-27 17:07:06 UTC
Created attachment 108561 [details]
Revised patch

I changed the way the custom editor is added to the NodePropertySupport. This change is a little less intrusive.
Comment 2 Jiri Rechtacek 2012-02-10 17:14:44 UTC
It needs to pass an API review process (http://wiki.netbeans.org/Review_Steps) before merging to product.
Comment 3 Jaroslav Havlin 2013-02-12 15:44:24 UTC
Created attachment 131300 [details]
Proposed Patch v3

I've updated the patch, protected constants CONNECTIONPROPERTIES and CONNECTIONPROPERTIESDESC moved from BaseNode to ConnectionNode, so that the public API is not changed at all.
Is it OK, Matthias, or do you think that these constants will be needed in some other subclasses of BaseNode?

Thank you for the patch!
Comment 4 matthias42 2013-02-12 20:45:36 UTC
Created attachment 131325 [details]
proposed patch v4

Hey,

yes I agree the changes to BaseNode can be pushed down into the connection node. But sorry - the API is still changed - I missed a change in org.netbeans.api.db.explorer.DatabaseConnection - this needs to expose access to the connection properties. I haven't looked the the relevant source code, but if I remember correctly there are uses of connections in the persistence framework, these modules need to adjust to the additional properties.

In addition I decided to have a look at the problem creating connections with properties and added a button calling the properties property editor to the new connection dialog. This integrates it IMHO quite well.

Sorry :-/

Matthias
Comment 5 Jaroslav Havlin 2013-02-13 10:40:24 UTC
Created attachment 131338 [details]
Proposed Patch v5

Increasing specification version, editing apichanges.xml, adding @since tag.

(In reply to comment #4)
> [...] the API is still changed - I missed a change in
> org.netbeans.api.db.explorer.DatabaseConnection - this needs to expose access
> to the connection properties. I haven't looked the the relevant source code,
> but if I remember correctly there are uses of connections in the persistence
> framework, these modules need to adjust to the additional properties.
OK, it's reasonable.

> In addition I decided to have a look at the problem creating connections 
> with properties and added a button calling the properties property editor 
> to the new connection dialog. This integrates it IMHO quite well.
We're considering showing the properties table in the next step in the wizard (instead of in dialog opened by clicking the button).
Do you know about any property that has to be set before testing the connection? If there is such a property for some databases, we have to set the properties in the same step as connection URL, but otherwise I think it is better to have a special step for setting properties.

> Sorry :-/
No problem at all. We'll start the review. Thank you for your help!
Comment 6 Jaroslav Havlin 2013-02-13 10:46:00 UTC
Please review this API change in module Database Explorer (db).

New method:
org.netbeans.api.db.explorer.DatabaseConnection.getConnectionProperties()

Thank you.
Comment 7 Sergey Petrov 2013-02-13 11:47:57 UTC
I'm new in this issue and may not got all details.

I see a lot of new methods, is DatabaseConnection.getConnectionProperties the only new public method?

Even it's unrelated api. I see all other DBConnection methods have javadoc and new ones have no javadoc. 

may it have sense to update javadoc for DatabaseConnection.getConnectionProperties to emphasize it will be copy of properties or changes will not affect a connection. I'm not sure what was initial use case, if it was supposed to have read only access in public.
How it is supposed to be used? And how to set properties? I see initial request was to set "there
seems to be some need for the ability to set the connection properties.".
Comment 8 matthias42 2013-02-13 11:54:13 UTC
(In reply to comment #5)
> > In addition I decided to have a look at the problem creating connections 
> > with properties and added a button calling the properties property editor 
> > to the new connection dialog. This integrates it IMHO quite well.
> We're considering showing the properties table in the next step in the wizard
> (instead of in dialog opened by clicking the button).
> Do you know about any property that has to be set before testing the
> connection? If there is such a property for some databases, we have to set the
> properties in the same step as connection URL, but otherwise I think it is
> better to have a special step for setting properties.

There are - informix need the INFORMIXSERVER property to be set either via JDBC
url or via properties. This has to be set to even be able to open a connection.
Comment 9 Jaroslav Havlin 2013-02-13 14:55:42 UTC
Created attachment 131350 [details]
Proposed Patch v6

Updated patch

(In reply to comment #7)
> I see a lot of new methods, is DatabaseConnection.getConnectionProperties the
> only new public method?
Yes, it was. The updated patch contains also new variant of public method DatabaseConnection.create(...), see below.

> Even it's unrelated api. I see all other DBConnection methods have javadoc and
> new ones have no javadoc.
Fixed.

> May it have sense to update javadoc for
> DatabaseConnection.getConnectionProperties to emphasize it will be copy of
> properties or changes will not affect a connection.
Sure. Fixed.

> I'm not sure what was initial use case, if it was supposed to have read 
> only access in public.
Some databases (in some cases) need specific connection properties to work correctly (e.g. Sybase and CHARSET, according to the forum). The patch allows users to specify these properties.

> How it is supposed to be used?
API clients can use the connection properties e.g. for java.sql.Driver.connect(String url, Properties info)

IDE users can set the properties when creating a new database connection.

> And how to set properties?
It's true that if the API allows clients to create DatabaseConnection objects and to get connection properties, it should also allow them to set the connection properties. 
I've added a new variant of method DatabaseConnection.create that accepts a Properties object.
Please check it.

(In reply to comment #8)
> > Do you know about any property that has to be set before testing the
> > connection?
> There are - informix need the INFORMIXSERVER property to be set either
> via JDBC  url or via properties. This has to be set to even be able to
> open a connection.
OK, so the properties need to be set in the same step.


Please review updated parts of the patch.
Thank you very much for your comments.
Comment 10 matthias42 2013-02-14 19:54:34 UTC
(In reply to comment #9)
> Please review updated parts of the patch.

Looks good to me.
Comment 11 Jaroslav Havlin 2013-02-20 09:35:56 UTC
If there are no objections, I'll integrate the patch tomorrow.
Thank you.
Comment 12 Jaroslav Havlin 2013-02-21 15:25:45 UTC
Integrated as http://hg.netbeans.org/core-main/rev/3eecc5103066
Thanks for your help.
Comment 13 Quality Engineering 2013-02-23 04:08:56 UTC
Integrated into 'main-golden', will be available in build *201302222300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/3eecc5103066
User: Jaroslav Havlin <jhavlin@netbeans.org>
Log: #197408: Enable editting of connection properties for db connections