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 148487 - No queries possible through odbc connection
Summary: No queries possible through odbc connection
Status: VERIFIED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Show Data (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P1 blocker (vote)
Assignee: John Baker
URL:
Keywords: REGRESSION
Depends on:
Blocks:
 
Reported: 2008-09-26 13:46 UTC by bartvdc
Modified: 2008-10-01 17:32 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
diffs (2.25 KB, text/plain)
2008-09-29 07:31 UTC, John Baker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bartvdc 2008-09-26 13:46:34 UTC
using nb daily 20080924 on win XP

I can make a connection through jdbc-odbc and see the tables . But when executing any query(thus also 'view data') I get
no result and this in the output :
Error code 0, SQL state null: Invalid Fetch Size
Line 1, column 1

I'm using the same connection in 6.1 and there it works.
There's no added line in the log. 
When I make a connection with jtds all works fine.

Ironically I started with odbc in nb6.1 because there I couldn't make a connection by jtds. 

Bart
Comment 1 John Baker 2008-09-26 19:46:57 UTC
which database, jdbc-odbc driver ?

Comment 2 John Baker 2008-09-26 20:16:11 UTC
From testing and user feedback, jtds has been more reliable than the Microsoft SQL Server driver.

So, JDBC-ODBC works with jtds driver?
Comment 3 John Baker 2008-09-27 00:52:46 UTC
I reproduced this using internal data source name, ravedbrussia  travel/travel
Comment 4 John Baker 2008-09-27 01:43:44 UTC
connection is possible but execution fails.

I'm having some trouble connectiong using ODBC on Linux so I'll have to go back to Windows and check-out a repository 
Comment 5 John Baker 2008-09-29 00:37:59 UTC
Appears there's a problem in org.netbeans.modules.db.dataview.output.prepareSQLStatement(...)
- setFetchSize (line 520) fails and some exception seems to be thrown - it's swallowed and no error logged.

After setFetchSize fails, the finally block of initialDataLoad(...) is entered so no data is return as a result of
executing a statment.

I created a datasource on rave-db.russia.sun.com, username/password is travel/travel (dbo schema)  that connects to
Microsoft SQL Server
After adding a JDBC-ODBC connection, I tried to execute - select * from dbo.Trip
Comment 6 John Baker 2008-09-29 00:44:13 UTC
Regressed since previous release
Comment 7 John Baker 2008-09-29 02:37:02 UTC
The exception that would be thrown is (after adding a catch clause in my local build)

java.sql.SQLException: Invalid Fetch Size
        at sun.jdbc.odbc.JdbcOdbcStatement.setFetchSize(JdbcOdbcStatement.java:826)
        at org.netbeans.modules.db.dataview.output.SQLExecutionHelper.prepareSQLStatement(SQLExecutionHelper.java:522)
        at org.netbeans.modules.db.dataview.output.SQLExecutionHelper.initialDataLoad(SQLExecutionHelper.java:105)
        at org.netbeans.modules.db.dataview.output.DataView.create(DataView.java:101)
        at org.netbeans.modules.db.dataview.api.DataView.create(DataView.java:71)
        at org.netbeans.modules.db.sql.execute.SQLExecuteHelper.execute(SQLExecuteHelper.java:105)
        at org.netbeans.modules.db.sql.loader.SQLEditorSupport$SQLExecutor.run(SQLEditorSupport.java:480)
Comment 8 John Baker 2008-09-29 07:11:54 UTC
b90aed8757d4
Comment 9 John Baker 2008-09-29 07:29:12 UTC
I have some problem with my repository.  I can push the fix tomorrow
Comment 10 John Baker 2008-09-29 07:31:55 UTC
Created attachment 70764 [details]
diffs
Comment 11 John Baker 2008-09-29 07:46:24 UTC
changeset will be different then the one mentioned earlier.
Mercurial was unable to find my username
Comment 12 Jayashri Visvanathan 2008-09-29 19:36:48 UTC
I am reassigning issue to you since you are working on a fix.
Comment 13 John Baker 2008-09-29 21:49:05 UTC
ff547554831a
Comment 14 Quality Engineering 2008-09-30 05:59:21 UTC
Integrated into 'main-golden', will be available in build *200809300201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/ff547554831a
User: John Baker <jbaker@netbeans.org>
Log: #148487 No queries possible through odbc connection
Comment 15 Roman Mostyka 2008-09-30 09:55:49 UTC
bartvdc, can You verify that this issue were really fixed, please?
Comment 16 bartvdc 2008-09-30 14:40:38 UTC
Verified with 20080930, it works.

Thanks for the fix,

Bart
Comment 17 Roman Mostyka 2008-09-30 14:52:02 UTC
Verified by reporter.
Comment 18 David Vancouvering 2008-09-30 16:44:25 UTC
DVC01 - Please set target mileston

DVC02 
@@ -173,7 +175,7 @@ public final class DBMetaDataFactory {
rs = dbmeta.getImportedKeys(setToNullIfEmpty(table.getCatalog()), setToNullIfEmpty(table.getSchema()), table.getName());
fkList = DBForeignKey.createForeignKeyColumnMap(table, rs);
} catch (SQLException e) {
- Exceptions.printStackTrace(e);
+ LOGGER.log(Level.WARNING, e.getMessage()); 

*Please* do *not* swallow an exception and then print only the message.  Those are so difficult to debug.  Please use

LOGGER.log(Level.WARNING, e.getMessage(), e);

This will print out the stack trace to the log.  

DVC03 - Why is this method swallowing the exception?  Why isn't it re-throwing the exception?  As a general policy you
don't want to swallow exceptions unless you have nobody to throw it to (e.g. you're in the run() method of a background
thread or you are the event handler for a user action).

DVC04 -
@@ -517,7 +517,11 @@ class SQLExecutionHelper {
stmt = conn.createStatement();
}
int pageSize = dataView.getDataViewPageContext().getPageSize();
- stmt.setFetchSize(pageSize);
+ try {
+ stmt.setFetchSize(pageSize);
+ } catch (SQLException e) {
+ // ignore - used only as a hint to the driver to optimize
+ }


Please log the exception with the INFO level, it's useful information and if we just swallow it we may not know why
things are behaving the way they are...
Comment 19 John Baker 2008-10-01 02:30:49 UTC
> - Exceptions.printStackTrace(e);
>+ LOGGER.log(Level.WARNING, e.getMessage()); 

> *Please* do *not* swallow an exception and then print only the message.  Those are so difficult to debug.  Please use

We should *not* be reporting the exception here.  Reporting an exception will interrupt the execution of the SQL and the
user (at least for using odbc) has no possible way to solve the error.   Execution should be allow to complete and any
error in executing SQL should be reported in the Output window.

If the exception is logged then this is not swallowing the exception.  Swallowing is leaving the catch empty or
excluding catch.

Actually the existing code could swallow other exceptions since previously there was no catch clause, only finally().


> + try {
> + stmt.setFetchSize(pageSize);
> +} catch (SQLException e) {
> + // ignore - used only as a hint to the driver to optimize
> + }

>Please log the exception with the INFO level, it's useful information and if we just swallow it we may not know why
things are behaving the way they are...

This try/catch was suggested by the owner of the code.   Perhaps we should have the owner of the code fix this.

Comment 20 Quality Engineering 2008-10-01 17:32:46 UTC
Integrated into 'main-golden', will be available in build *200810011401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/174cb881b834
User: John Baker <jbaker@netbeans.org>
Log: #148487 improve logging