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 103161 - Create data source munges URL (MSSQL Server)
Summary: Create data source munges URL (MSSQL Server)
Status: VERIFIED FIXED
Alias: None
Product: serverplugins
Classification: Unclassified
Component: Sun Appserver 9 (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P2 blocker (vote)
Assignee: Nitya Doraisamy
URL:
Keywords: REGRESSION
: 76686 (view as bug list)
Depends on:
Blocks: 111037
  Show dependency tree
 
Reported: 2007-05-02 17:47 UTC by Roman Mostyka
Modified: 2007-08-06 21:18 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
IDE's log (60.33 KB, text/plain)
2007-05-02 17:48 UTC, Roman Mostyka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Mostyka 2007-05-02 17:47:48 UTC
1. Add MS SQL Server connection. I used:
jdbc:sqlserver://rave-db:1433;DatabaseName=master;SelectMethod=cursor
2. Create project. Add 'Table' component to the page.
3. Click table from DB and then click on 'Table' component on the page.

Result: Exception arises. And 'Table' component is not bound to DB.
If I click on the page, then RowSet and DataProvider are created, but when I
tried bound table to DataProvider it was RED.
Comment 1 Roman Mostyka 2007-05-02 17:48:40 UTC
Created attachment 42060 [details]
IDE's log
Comment 2 John Baker 2007-05-02 18:00:28 UTC
is there a datasource created under Data Source References node.
and if so, what is the name generated ?
Comment 3 Roman Mostyka 2007-05-02 19:21:50 UTC
Datasource's name is 'dbo_MicrosoftSQLServer'.
DB's schema is called 'dbo'.
Comment 4 _ jimdavidson 2007-05-02 19:43:17 UTC
I reproduced the problem, using a database here.

URL:
jdbc:sqlserver://rave-cheetah.sfbay.sun.com:1433;DatabaseName=travel;SelectMethod=cursor

The failure occurs because the method DesignTimeDatasource.getConnection()
cannot find a connection.

That happens because of a mismatch:

The URL property of the DesignTimeDatasource is set to: 
jdbc:sqlserver://jdbc:sqlserver://rave-cheetah.sfbay.sun.com:1433

But, the URL for the appropriate connection is:
jdbc:sqlserver://rave-cheetah.sfbay.sun.com:1433;DatabaseName=travel;SelectMethod=cursor

So, no match is found.

I think the URL of the DesignTimeDataSource is wrong.

John, does this look like something in your area?
Comment 5 John Baker 2007-05-02 21:44:17 UTC
it appears the serverplugin is failing to add any datasources to the project.
More evaluation is needed.
Comment 6 John Baker 2007-05-02 21:58:58 UTC
it appears the serverplugin is failing to add any datasources to the project.
More evaluation is needed.

Will investigate for M10 and release note for M9

A workaroud is to use the jTDS driver
http://sourceforge.net/project/showfiles.php?group_id=33291
Comment 7 _ jimdavidson 2007-05-02 22:23:06 UTC
Per discussion with John and Jayashri, this is not a show-stopper for M9.

One workaround is to use jTDS.

The problem may lie in the MS driver, or in the serverplugin module, or both. 
If possible, we should be able to add a driver-specific workaround.

Expect to have something for M10.
Comment 8 Joseph Silber 2007-05-03 12:29:12 UTC
Release note added
Comment 9 Dan Kolar 2007-06-13 13:10:42 UTC
workaround found, P1->P2
Comment 10 _ jimdavidson 2007-07-03 06:13:19 UTC
I confirmed that
- this is still an issue in M10;
- jTDS is still a valid workaround

The problem is that we end up with mismatched URL's, as the earlier message indicates.  We create a datasource with URL:
jdbc:sqlserver://rave-cheetah.sfbay.sun.com:1433;DatabaseName=travel;SelectMethod=cursor

But later on we find one with URL:
jdbc:sqlserver://rave-cheetah.sfbay.sun.com:1433

I.e., truncated.

Assigning the John B to investigate, since it's a datasource issue.
Comment 11 John Baker 2007-07-03 07:37:31 UTC
Issues with target release should be resolved for the milestone.
This was marked as target release M10 then reassigned to me after M10 had been released
Comment 12 John Baker 2007-07-04 01:18:25 UTC
previous evaluation was incorrect.

metadata is null.

The url property of dataSource and connection are actually set correctly in DatabaseMetaData 
(jdbc:sqlserver://rave-cheetah.sfbay.sun.com:1433;DatabaseName=travel;SelectMethod=cursor)

connection is set on line 439 of DatabaseMetaData via:

connection = dataSource.getConnection();


but the statement below on line 444, to retrieve the metadata fails:

 metaData = getConnection().getMetaData();

In DatabaseMetaData.getTablesInternal(...) , the metadata property of the resultset is null

This appears to be a driver issue and we may not be able to do anything about this.

 Handing back to Jim

Comment 13 _ jimdavidson 2007-07-18 06:02:33 UTC
Not a driver problem; the driver returns an instance of SQLServerDatabaseMetadata, as it should.
Looks like a server plugin problem.

My previous analysis stands.  We create a datasource (via ProjectDataSourceManager.addDataSource()) with the url:
"jdbc:sqlserver://rave-cheetah.sfbay.sun.com:1433;DatabaseName=travel;SelectMethod=cursor"

When we retrieve the datasources (via ProjectDataSourceManager.getDataSourceWithName()), we get back one with the url:
"jdbc:sqlserver://rave-cheetah.sfbay.sun.com:1433" -- i.e.,  missing DatabaseName and SelectMethod.  They are also
missing from the sunresources.xml file.

Because of this, the DesignTimeDataSource (which tests the URLs for equality) cannot find a connection that matches the
datasource, so the call to getMetaData() returns null.

Solution is to figure out why the URL is being munged.  This didn't happen in 5.5 (with the same drivers), and it
doesn't happen with jTDS.

Assigning back to John, to get this fixed.  May require a fix from the server plugin people.
Comment 14 John Baker 2007-07-18 20:32:05 UTC
This prevents using MSSQL Server driver with visualweb applications.

The data source may not be getting created successfully since the url appears as  munged when retrieved using

// Attempt to create a data source that has a JDBC URL
"jdbc:sqlserver://rave-cheetah.sfbay.sun.com:1433;DatabaseName=travel;SelectMethod=cursor"

J2eeModuleProvider jmp =
                (J2eeModuleProvider)project.getLookup().lookup(J2eeModuleProvider.class);

  jmp.getConfigSupport().createDatasource(req.getResourceName(), req.getUrl(),
                        req.getUsername(), req.getPassword(), req.getDriverClassName());

// here in the createDatasource, the url is passed in as
"jdbc:sqlserver://rave-cheetah.sfbay.sun.com:1433;DatabaseName=travel;SelectMethod=cursor"

// later on when retrieving the data source...
        J2eeModuleProvider jmp =
                (J2eeModuleProvider)p.getLookup().lookup(J2eeModuleProvider.class);
        Set<Datasource> dss = null;
        try {
            dss = jmp.getServerDatasources();
        } catch (ConfigurationException e) {
            dss = new HashSet<Datasource>();
            // TODO: give some feedback to the user
        }
        Set<RequestedJdbcResource> reqDss = new HashSet<RequestedJdbcResource>();
        Iterator<Datasource> it = dss.iterator();
        
        while (it.hasNext()) {
            Datasource ds = it.next();
            RequestedJdbcResource r = new RequestedJdbcResource(ds.getJndiName(),ds.getDriverClassName(),
                    ds.getUrl(), null, ds.getUsername(), ds.getPassword(), null);
                        
            reqDss.add(r);
        }
ds.getUrl() returns the url munged as "jdbc:sqlserver://rave-cheetah.sfbay.sun.com:1433"


 Set<Datasource> dss = null;
        try {
            dss = jmp.getModuleDatasources();
        } catch (ConfigurationException e) {
            dss = new HashSet<Datasource>();
            // TODO: give some feedback to the user
        }
        
        Set<RequestedJdbcResource> reqDss = new HashSet<RequestedJdbcResource>();
        Iterator<Datasource> it = dss.iterator();
                
        while (it.hasNext()) {
            Datasource ds = it.next();
            RequestedJdbcResource r = new RequestedJdbcResource(ds.getJndiName(),ds.getDriverClassName(),
                    ds.getUrl(), null, ds.getUsername(), ds.getPassword(), null);
            
            reqDss.add(r);
        }
Comment 15 John Baker 2007-07-18 20:34:03 UTC
Note MSSQL server worked fine with visualweb in previous releases. 5.5 and 5.5.1
Comment 17 Roman Mostyka 2007-08-03 17:11:25 UTC
Verified with build 070803.
Comment 18 Nitya Doraisamy 2007-08-06 21:18:48 UTC
*** Issue 76686 has been marked as a duplicate of this issue. ***