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 147365 - Error message appears after refreshing MS SQL Server
Summary: Error message appears after refreshing MS SQL Server
Status: RESOLVED DUPLICATE of bug 146442
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Rob Englander
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-16 12:50 UTC by Roman Mostyka
Modified: 2008-09-18 17:05 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Screenshot of "Error" message. (72.55 KB, image/jpeg)
2008-09-16 12:51 UTC, Roman Mostyka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Mostyka 2008-09-16 12:50:31 UTC
1. Add MS SQL Server driver.
2. Add connection to MS SQL Server.
3. Expand "Tables" node and disconnect.
4. Connect again, rightclick and choose "Refresh".

Result: Error message appears.
Comment 1 Roman Mostyka 2008-09-16 12:51:09 UTC
Created attachment 69941 [details]
Screenshot of "Error" message.
Comment 2 David Vancouvering 2008-09-16 17:08:55 UTC
It is true the connection is closed.  What is it you are looking for?  A better error message that doesn't say "Unable
to refresh children"?

Would you prefer that we offer to reconnect to the database?

I can guess what you want here, but I'd rather get it explicitly, so that we don't go back and forth with me closing the
issue and you reopening it :)
Comment 3 David Vancouvering 2008-09-16 17:09:31 UTC
Also, can you reproduce this with other databases like MySQL, or only with MS SQL Server?
Comment 4 Roman Mostyka 2008-09-17 13:08:25 UTC
It is true the connection is closed.  What is it you are looking for?  A better error message that doesn't say "Unable
to refresh children"?
If you look at step 4, you will see following:
"4. Connect again, rightclick and choose "Refresh"."
So I reconnected and got error after this. And this is a problem. ;)
And I also can reproduce this with Java DB, so I think this problem can occur for every DB.
Comment 5 Rob Englander 2008-09-17 13:56:40 UTC
I'll do this.  I just bumped into it last night myself.
Comment 6 Rob Englander 2008-09-17 15:38:49 UTC
This happens because the child nodes are handed a copy of the property set from the parent upon creation.  Upon
reconnect the driver specification property is updated in the ConnectionNodeInfo but that doesn't get reflected in its
children.  

My proposed fix (already tested in my sandbox) is to update the appropriate property in the child nodes when the driver
specification is modified.

Anyone have any objections to this?

BTW, a better model IMO would be to use an inheritance model for properties.  Children would only keep properties that
are specific to themselves, and would delegate the rest to their parents.  I'm not proposing this approach right now,
but it might be a useful technique in the future.
Comment 7 Rob Englander 2008-09-18 13:56:51 UTC
It looks like the fix I had proposed (using property inheritance) has been implemented by someone for some other issue.

Let me know which issue it was and I'll refer this one to it and close this one.

The fix I found this morning is in DatabaseNodeInfo.  It now delegates to the parent for properties.
Comment 8 David Vancouvering 2008-09-18 17:05:47 UTC
Geez, I remember your proposal going by but at the time it didn't sink in.  Sorry about that!

Yes, I did this to solve issue 146442, where if a server is restarted or a connection times out, instead of just
reporting an exception, now I report a nice dialog and give the user the option to reconnect.  

The problem was that after reconnect, the DriverSpecification was getting set on the ConnectionNodeInfo, but the child
Node Infos were not getting it.  Their DriverSpecification property (and other properties) are copied from the parent
when the Node Info is initialized but after that the Node Info instance is isolated and does not notice changes to the
parent.  The DriverSpecification has a reference to DatabaseMetadata which is used for MD calls, and the old DriverSpec
was pointing to the old JDBC connection which is now closed.

So now when you call getDriverSpecification, you get it from the ConnectionNodeInfo.  Same for other similar properties
related to connection state.

The whole thing is very odd, and hopefully we can resolve this when we look at a rewrite.

I'm closing this issue as a duplicate of 146442

*** This issue has been marked as a duplicate of 146442 ***