Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 166549 - JDBC SQLServer : cannot show data from non-default database
JDBC SQLServer : cannot show data from non-default database
Status: RESOLVED FIXED
Product: db
Classification: Unclassified
Component: Code
6.x
PC Windows Vista
: P3 (vote)
: 6.x
Assigned To: Jiri Rechtacek
issues@db
: NETFIX
: 160269 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-06-04 13:38 UTC by neuros_nid
Modified: 2009-07-30 05:59 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
hg diff of QueryAction.java (8.22 KB, patch)
2009-06-29 21:09 UTC, dynamite
Details | Diff
QueryAction.java (9.37 KB, text/plain)
2009-06-29 21:11 UTC, dynamite
Details

Note You need to log in before you can comment on or make changes to this bug.
Description neuros_nid 2009-06-04 13:38:24 UTC
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
Comment 1 dynamite 2009-06-29 21:07:21 UTC
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).
Comment 2 dynamite 2009-06-29 21:09:22 UTC
Created attachment 84149 [details]
hg diff of QueryAction.java
Comment 3 dynamite 2009-06-29 21:11:11 UTC
Created attachment 84150 [details]
QueryAction.java
Comment 4 dynamite 2009-06-29 21:17:38 UTC
I was using the jTDS driver for SQLServer.  I have tested this against SQLServer and MySQL with success.
Comment 5 dynamite 2009-07-17 14:02:22 UTC
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.
Comment 6 Jiri Kovalsky 2009-07-17 14:18:59 UTC
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 [1] team.

[1] http://wiki.netbeans.org/NetFIX
Comment 7 Jiri Rechtacek 2009-07-27 09:03:53 UTC
I'm investigating the problem and I'll review the patch. Thanks for the patch.
Comment 8 dynamite 2009-07-27 21:26:14 UTC
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
SQLite.
Comment 9 Jiri Rechtacek 2009-07-29 14:29:00 UTC
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
Comment 10 Jiri Rechtacek 2009-07-29 15:43:12 UTC
*** Issue 160269 has been marked as a duplicate of this issue. ***
Comment 11 Quality Engineering 2009-07-30 05:59:30 UTC
Integrated into 'main-golden', will be available in build *200907300201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/f06457e60c13
User: Jiri Rechtacek <jrechtacek@netbeans.org>
Log: #166549: JDBC SQLServer : cannot show data from non-default database (applied dynamite's patch, thanks)


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo