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 108422 - No way to acquire a JDBC connection without the user being prompted for a password
Summary: No way to acquire a JDBC connection without the user being prompted for a pas...
Status: RESOLVED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All Windows XP
: P2 blocker (vote)
Assignee: John Baker
URL:
Keywords: API
Depends on: 100716
Blocks: 212916
  Show dependency tree
 
Reported: 2007-06-28 15:25 UTC by giorgio42
Modified: 2012-05-23 20:06 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description giorgio42 2007-06-28 15:25:13 UTC
[Description is copied from this openide-dev post:
http://www.nabble.com/Experimenting-with-the-Database-Explorer-API-tf2280369.html#a6334571]

I have not found a way to get a JDBC connection without the user being prompted for a password.
Even if I specify all parameters in DatabaseConnection.create(), including the password, the connection
dialog still appears when trying to connect (contrary to the javadoc description).

      DatabaseConnection databaseConnection =
            DatabaseConnection.create
                    ( jdbcDrivers[0]
                    , databaseUrl
                    , user
                    , schema
                    , password
                    , true
                    );
      ConnectionManager.getDefault().showConnectionDialog( databaseConnection );
      jdbcConnection = databaseConnection.getJDBCConnection();

Business case: Using the db explorer API it is not possible to write a database-oriented NB module, that does not prompt
the user for database account and password. Often the users of an NB module or NB platform-based application must not
even know that the application is backed by a database.

Regards,
Georg
Comment 1 Andrei Badea 2007-06-29 15:32:00 UTC
Georg, I tried and this works for me. The following code:

    JDBCDriver mysqlDriver = null;
    for (JDBCDriver driver : JDBCDriverManager.getDefault().getDrivers()) {
        if (driver.getDisplayName().toLowerCase().contains("mysql")) {
            mysqlDriver = driver;
            break;
        }
    }
    DatabaseConnection conn = DatabaseConnection.create(mysqlDriver, "jdbc:mysql://localhost/test", "test", null,
"test", true);
    try {
        ConnectionManager.getDefault().addConnection(conn);
    } catch (DatabaseException databaseException) {
        return;
    }
    ConnectionManager.getDefault().showConnectionDialog(conn);

doesn't ask for the password, it just displays a "Connect" progress window.

Is the "Remeber password" property set to true in the properties of the new connection?
Comment 2 John Baker 2007-07-04 08:36:35 UTC
I'll investigate this more.
I had experienced the same behavior as the submitter but I moved on to more important tasks
Comment 3 John Baker 2007-07-04 08:38:23 UTC
I may be able to get to this by beta1 but will mark for beta2 just in case I don't complete for beta1
Comment 4 John Baker 2007-07-19 04:03:36 UTC
In DB Explorer UI, opening the property sheet of a connection, the "rememberPassword" property for a database connection
is checked (enabled).
This should signify a true value and the password should be remembered.

While debugging DatabaseConnection, showConnectionDialog()  on line 750, the method findConnectionNodeInfo(getName())
returns a ConnectionNodeInfo.  

Some property, rememberpwd of ConnectionNodeInfo is set to "false" on line 750
I think it should be set to true.  

If related, there is an inherited property, passwordWasSet and this too is set to "false"

As a result, everytime I invoke ConnectionManager.getDefault().showConnectionDialog(conn);
The connection dialog opens prompting me for a password

  Something doesn't seem right.


Comment 5 Andrei Badea 2007-07-20 10:52:57 UTC
I removed passwordWasSet, it seemed unused.

I'm still not sure wheter you call showConnectionDialog() *in the same session* that you registered it in. Do you?
Comment 6 Andrei Badea 2007-07-23 12:03:26 UTC
From reporter by private e-mail:

The request behind this bug report is to provide the possibility to connect
to databases based on the db explorer API "anywhere and anytime" without a
database connection dialog appearing, therefore completely independent from
any "sessions".
Comment 7 Andrei Badea 2007-07-23 12:13:01 UTC
Then it is a duplicate of issue 87600 after all. Georg, sorry for the mess. I thought you got the connection dialog even
if connecting in the same session that you created the connection in. That should not happen. But you currently always
get the dialog when connecting (at least for the first time) in another IDE session (i.e., after a restart).
Comment 8 Andrei Badea 2007-09-14 10:40:39 UTC
Sorry, but this is not a defect. There was never a plan to support connecting '"anywhere and anytime" without a
database connection dialog appearing'. I would have been a defect if you got the Connect dialog in the same IDE session
that you created the connection (specifying its password). But I understand that is not the case.

I agree it would be good to support this though. John, do you really plan to work on this for beta 2?
Comment 9 John Baker 2007-09-19 09:10:41 UTC
From the example in desc2, the remember password is set to true, but the connection created has a remember password
property that is set to false (based on the property sheet for the connection created)  I'll look into this tomorrow

JDBCDriver mysqlDriver = null;
    for (JDBCDriver driver : JDBCDriverManager.getDefault().getDrivers()) {
        if (driver.getDisplayName().toLowerCase().contains("mysql")) {
            mysqlDriver = driver;
            break;
        }
    }
    DatabaseConnection conn = DatabaseConnection.create(mysqlDriver, "jdbc:mysql://localhost/test", "test", null,
"test", true);
Comment 10 Andrei Badea 2007-10-25 13:56:05 UTC
Georg, the part that interests you has been fixed. The DB Explorer now stores the password between sessions. If you can
still reproduce the Connect dialog popping up when it shouldn't have, please file an issue.

John, do you plan to do anything more in this issue? If not, can you please close it?
Comment 11 giorgio42 2007-10-26 23:40:59 UTC
A big Thank You! to all that have been involved. It seems this caused a lot more work than I would have anticipated.

Currently I am under heavy load from my day job, but I will try out the new feature as soon as possible.

Best regards,
Georg
Comment 12 David Vancouvering 2008-02-22 17:49:03 UTC
Hi, Georg.  I think this is fixed, can you verify?