In Netbeans 6.5, the BDD Services interface only displayed the selected database and the selected schema (as confirmed
by the text "for each database connection, the service window only display objects from one database schema" when
creating a new connection). Everything was OK.
In NetBeans 6.7, the full schema is displayed (all databases, all schemas, then the tables).
However, the default database is taken into account. When displaying one table data, the SQL request take this
form : "SELECT * FROM dbo.TABLE_NAME". So when clicking on "display data" on a non-default database, it leads to an
error message : 'Invalid Object Name dbo.TABLE_NAME', as the database name is not mentionned in the query.
This is the same frustrating behaviour as in Eclipse.
Tested under Vista and Linux, with the Microsoft SQL Server JDBC drivers 1.1, 1.2 and 2.0
I too have seen this issue and I now have a fix ready! The code that generates the SQL is in
org.netbeans.modules.db.explorer.action.QueryAction class. This compared the name of the selected table's schema
against the default schema name. This is not however populated, presumably because the code was left mid-development
(note the greyed-out menu option to change the default catalog/schema). Additionally the code did not perform the same
check for the catalog (database in SQLServer terminology).
My fix checks the selected table's catalog and schema against the one for the database connection and only attaches it
to the table name in the query if they are different. The table's schema is only checked if the schema name is not null
(which is notably the case for MySQL).
Created attachment 84149 [details]
hg diff of QueryAction.java
Created attachment 84150 [details]
I was using the jTDS driver for SQLServer. I have tested this against SQLServer and MySQL with success.
I am currently using the DB explorer a lot a work. A few weeks ago out of curiosity I had a look into whether I could
avoid opening multiple connections for the same database and when I succeeded this proved very helpful. I then went to
raise an issue and found that this one had already been created, and so I attached the patch.
I have in the last day or so become a NetFIX member and realised that I have performed the process in reverse, for which
I apologise. I wonder if you would consider this as a NetFIX fix.
Jirko, would you be willing to review Daniel Sheppard's (dynamite) patch and integrate it if you find no problems?
Thanks a lot! Daniel is new member of NetFIX  team.
I'm investigating the problem and I'll review the patch. Thanks for the patch.
Thanks. To avoid confusion I should say that my patch was written prior to your patch for issue #167564. I think that
the patch I have included ought to satisfy that issue as well, although I must confess that I haven't tested it against
Thanks for the patch. It's was applied in core-main/rev/f06457e60c13.
@dynamite: The proposed patch contains the patch of issue #167564, actually. Your patch fixes both cases - either using
non-default databases or querying SQLite as well. Thanks
*** Issue 160269 has been marked as a duplicate of this issue. ***
Integrated into 'main-golden', will be available in build *200907300201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
User: Jiri Rechtacek <firstname.lastname@example.org>
Log: #166549: JDBC SQLServer : cannot show data from non-default database (applied dynamite's patch, thanks)