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 149317

Summary: Cannot use mysql db connection defined with empty password
Product: db Reporter: Nitya Doraisamy <nityad>
Component: MySQLAssignee: Jiri Rechtacek <jrechtacek>
Status: RESOLVED INCOMPLETE    
Severity: blocker CC: davidvc, gowri, jayashri, kganfield, pjiricka, tmysik
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: error message
Database Connections

Description Nitya Doraisamy 2008-10-07 07:08:01 UTC
If MySQL is installed without specifying a password, then that database connection cannot be used in the 'Use Database
..' action to create JDBC resources.

To reproduce:
- install MySQL without a root password (or change the root password to blank)
- connect to MySQL and create a new sample database 
- the database connection is successfully created

But this connection cannot be used to create a JDBC resource. This is a valid usecase.
Comment 1 martin_adamek 2008-10-07 14:42:20 UTC
So what should be the expected behavior?
Comment 2 Vince Kraemer 2008-10-07 16:24:44 UTC
see issue 149286
Comment 3 martin_adamek 2008-10-08 10:06:47 UTC
In servlet I am able to call Use database action -> Add reference -> Add project data source -> select mysql connection without pasword -> and finish the 
wizard. Closing as WFM. Feel free to reopen with exact steps to reproduce.
Comment 4 Nitya Doraisamy 2008-10-08 22:03:21 UTC
I am still able to reproduce this issue using the following steps,

- Register a sampledb (for MySQL) with no password. Note, I checked the box to save password.
- Try to create a datasource with this connection using 'Use Database..' action worked.
- Shutdown and Start the IDE.
- Go to project and attempt to create a datasource with the same connection using 'Use Database..' action 
- This gives error message : ' The password must be provided, otherwise the data source cannot be created'

I don't remember having  restart the IDE to get into this situation yesterday, but I could be mistaken.

Attached screenshots s

Comment 5 Nitya Doraisamy 2008-10-08 22:04:49 UTC
Created attachment 71422 [details]
error message
Comment 6 Nitya Doraisamy 2008-10-08 22:05:23 UTC
Created attachment 71423 [details]
Database Connections
Comment 7 martin_adamek 2008-10-10 11:27:33 UTC
Tomasi (asking you as an author) - DataSourceReferencePanel.isEnabled depends on whether password is null. Is that correct? 
DatabaseConnection.getPassword() can be null even in this valid usecase of empty password.
Comment 8 Tomas Mysik 2008-10-10 11:47:27 UTC
Really hard to say, I'm not sure; but seems to me that the check is OK - at least if you have a look at 
DatasourceComboBoxCustomizer:164 you can see that the check is there and if the password is null, false is returned 
and the customizer is then invalid (that code was there before I made my changes).
Comment 9 martin_adamek 2008-10-10 13:38:35 UTC
Yes, I was looking there and that check should be disabled. I tried to do that and fix was pretty simple. Anyway, I would like to discuss this with Andrei 
(should be able to see the things from DB point of view) on monday before applying it.
Comment 10 martin_adamek 2008-10-13 09:09:33 UTC
After discussion with Andrei, I decided to downgrade to P2. Main reason is that using mysql without password is very rare and it still can be fixed by setting 
one. Also from the implementation point of view, it is quite undefined on how DatabaseConnection.getPassword() is behaving and it will require bigger effort 
also in DB modules to ensure proper behavior.
Comment 11 Jayashri Visvanathan 2008-12-12 19:33:25 UTC
David,
  Any changes in this area in 7.0 so that this address can be addressed ?
thanks
Comment 12 _ gowri 2008-12-12 20:07:39 UTC
From the thread I feel like its related to databases. Assigning to David. David, please resend it if you think its not
yours.
Comment 13 David Vancouvering 2008-12-12 21:10:52 UTC
I'm not sure what to do here.  Can somebody explain the problem from the Database Explorer API point of view?   A
database password can be null, and when it is, we return null when you say getPassword().  

One thing that happens is when the password is saved, we save it as an empty string, otherwise savePassword checkbox
doesn't work, because we think the password is empty instead of saved.  So next time you call getPassword(), it returns
an empty string. 

I think the problem may be related to the age-old problem between NULL (not specified) and "none" - specified, and it's
empty.

But again, I'm not sure what exactly the problem is and how I can fix it...
Comment 14 Jiri Rechtacek 2009-02-10 15:26:07 UTC
Reassigned to new owner.
Comment 15 Jiri Rechtacek 2009-09-18 10:09:00 UTC
David's question hasn't been answered yet, I'm going to close as WFM.