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 89532 - If JDBC url excludes the port number then a ":" is still injected in the url
Summary: If JDBC url excludes the port number then a ":" is still injected in the url
Status: RESOLVED FIXED
Alias: None
Product: serverplugins
Classification: Unclassified
Component: Code (show other bugs)
Version: 5.x
Hardware: All All
: P1 blocker (vote)
Assignee: Nitya Doraisamy
URL:
Keywords:
: 86586 (view as bug list)
Depends on:
Blocks: 98890
  Show dependency tree
 
Reported: 2006-11-17 10:33 UTC by John Baker
Modified: 2007-04-05 03:24 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
diff of fix for the case when a JDBC URL does not contain a port number (1.08 KB, application/octet-stream)
2007-04-05 02:42 UTC, John Baker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Baker 2006-11-17 10:33:36 UTC
Connecting to  a MySQL doesn't always require a port number in the URL
After adding a connection it turns out that a ':' is included in the url
following the server name

e.g. 
jdbc:mysql://jbrave-pc1.sfbay.sun.com:/travel

Possibly, the culprit is line 606 of ResourceConfigurator where the serverPort 
is set to hostName + ":" + portNumber; 

Unfortunately portNumber would be empty for the jdbc url mentioned above

As a result, JDBC applications (that use urls without port numbers) and 
serverplugins to obtain database resources will fail to connect to databases.
Comment 1 Vince Kraemer 2006-11-25 18:37:22 UTC
work-around... put the port into the URL...
Comment 2 Vince Kraemer 2006-12-22 18:42:40 UTC
Steps to reproduce?

I cannot tell which UI elements that deal with JDBC URL's is getting used.
Comment 3 John Baker 2007-01-12 02:38:17 UTC
The initial evaluation may be incorrect - bug in ResourceConfigurator, although
the code doesn't look correct, wouldn't work if a URL doesn't contain a port 
number.

Here is the code used to obtain the url.  
ds.getUrl() retrieves a URL that contains the extra colon (assumes a port)


public Set<RequestedJdbcResource> getProjectDataSources(Project p) {
        J2eeModuleProvider jmp =
                (J2eeModuleProvider)p.getLookup().lookup(J2eeModuleProvider.class);
        Set<Datasource> dss = jmp.getModuleDatasources();
        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);
        }
        
        return reqDss;
    }
Comment 4 Vince Kraemer 2007-01-12 16:22:20 UTC
It is still unclear where you entered the jdbc url and/or other connection
information in the first place.

Please provide some indication of the user actions that you took....

The code snippet you are proving contains no serverplugin code.

What type of project were you working with?
Comment 5 John Baker 2007-01-12 19:22:01 UTC

In the Runtime tab, after adding the MySQL driver and connection with
url missing the port number (not needed when the default port number is used)
Connection to MySQL is successful - View Data works.

The problem occurs when trying to obtain the project's datasource.
Somehow, an extra colon is added to the url.  As a result binding a MySQL
rowset to a VWP component fails.  I had to add a hack in VWP to get around
this invalid url problem.

The code provided to obtain the project's datasource is the code used to obtain 
the url.  

In the code provided, although Datasource and J2eeModuleProvider are not from
the plugin, however, in serverplugins, ConfigurationSupportImpl there is a
getDatasources method.  The Datasource url is not retrieved correctly as 
described.

I don't know if the bug is in getDatasources or some other method to retrieve
a datasource, but appears to be somewhere in the plugin or j2ee module



Comment 6 Vince Kraemer 2007-02-06 22:31:09 UTC
*** Issue 86586 has been marked as a duplicate of this issue. ***
Comment 7 John Baker 2007-03-23 07:09:46 UTC
With Visual WebPack 6.0 M8 with a Java EE 5 project and a MySQL connection which
doesn't include a port number, drag and drop a database table to the Designer
complains about a missing port number.

Can this be fixed for M9?

Comment 8 John Baker 2007-04-05 01:02:16 UTC
This bug is still there.  This is a P1 for visualweb.
Comment 9 John Baker 2007-04-05 02:38:41 UTC
ResourceConfigurator is used to create a url for the datasource to be created.
But if a JDBC URL does not contain a port number then a ":" is injected in the url:

jdbc:mysql://jbrave-pc1.sfbay.sun.com:/travel

Attached is a diff of what to fix


Comment 10 John Baker 2007-04-05 02:42:25 UTC
Created attachment 40465 [details]
diff of fix for the case when a JDBC URL does not contain a port number