[hg] main-silver: #225609: IllegalStateException: The Java DB (N...

  • From: Jaroslav Havlin < >
  • To:
  • Subject: [hg] main-silver: #225609: IllegalStateException: The Java DB (N...
  • Date: Fri, 08 Feb 2013 20:37:20 -0800

changeset 62c8254e25fc in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/62c8254e25fc
description:
        #225609: IllegalStateException: The Java DB (Network) driver was not 
found

diffstat:

 derby/src/org/netbeans/modules/derby/Bundle.properties          |   2 +
 derby/src/org/netbeans/modules/derby/ConnectDatabaseAction.java |  24 
+++++++++-
 2 files changed, 24 insertions(+), 2 deletions(-)

diffs (67 lines):

diff --git a/derby/src/org/netbeans/modules/derby/Bundle.properties 
b/derby/src/org/netbeans/modules/derby/Bundle.properties
--- a/derby/src/org/netbeans/modules/derby/Bundle.properties
+++ b/derby/src/org/netbeans/modules/derby/Bundle.properties
@@ -84,6 +84,8 @@
 ERR_DirectoryDoesNotExist=The directory {0} does not exist.
 ERR_DirectoryIsNotWritable=The directory {0} is not writable.
 ERR_EnterDerbyLocation=The Java DB installation directory is empty.
+# {0} - Driver name
+ERR_DerbyDriverNotFoundConfigure=The {0} driver was not found.\nDo you want 
to add it now?
 
 #Installer
 MSG_RegisterJavaDB=Registering the Java DB database.
diff --git a/derby/src/org/netbeans/modules/derby/ConnectDatabaseAction.java 
b/derby/src/org/netbeans/modules/derby/ConnectDatabaseAction.java
--- a/derby/src/org/netbeans/modules/derby/ConnectDatabaseAction.java
+++ b/derby/src/org/netbeans/modules/derby/ConnectDatabaseAction.java
@@ -42,7 +42,6 @@
 
 package org.netbeans.modules.derby;
 
-import java.util.Arrays;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -52,6 +51,8 @@
 import org.netbeans.api.db.explorer.DatabaseException;
 import org.netbeans.api.db.explorer.JDBCDriver;
 import org.netbeans.api.db.explorer.JDBCDriverManager;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
 import org.openide.nodes.Node;
 import org.openide.util.HelpCtx;
 import org.openide.util.NbBundle;
@@ -101,7 +102,8 @@
             {
                 JDBCDriver drivers[] = 
JDBCDriverManager.getDefault().getDrivers(DerbyOptions.DRIVER_CLASS_NET);
                 if (drivers.length == 0) {
-                    throw new IllegalStateException("The " + 
DerbyOptions.DRIVER_DISP_NAME_NET + " driver was not found"); // NOI18N
+                    showDriverNotFoundDialog();
+                    return;
                 }
                 final DatabaseConnection dbconn = 
DatabaseConnection.create(drivers[0], "jdbc:derby://localhost:" + // NOI18N
                         RegisterDerby.getDefault().getPort() +
@@ -133,6 +135,24 @@
         }
     }
 
+    /**
+     * If Derby driver cannot be found, show info message and ask user 
whether
+     * they want to open the Add Driver dialog.
+     *
+     * See bug #225609.
+     */
+    private void showDriverNotFoundDialog() {
+        String msg = NbBundle.getMessage(ConnectDatabaseAction.class,
+                "ERR_DerbyDriverNotFoundConfigure", //NOI18N
+                DerbyOptions.DRIVER_DISP_NAME_NET);
+        NotifyDescriptor nd = new NotifyDescriptor.Confirmation(
+                msg, NotifyDescriptor.YES_NO_OPTION);
+        DialogDisplayer.getDefault().notify(nd);
+        if (NotifyDescriptor.YES_OPTION.equals(nd.getValue())) {
+            JDBCDriverManager.getDefault().showAddDriverDialog();
+        }
+    }
+
     @Override
     public HelpCtx getHelpCtx() {
         return new HelpCtx(ConnectDatabaseAction.class);

[hg] main-silver: #225609: IllegalStateException: The Java DB (N...

Jaroslav Havlin 02/09/2013

Project Features

About this Project

DB was started in November 2009, is owned by Antonin Nebuzelsky, and has 113 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close