New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding command for New Database Connection #3358
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine at first round:
- properly version the DB module API changes
- avoid needless changes in
platform.properties
- write a test for the new method
- try to avoid references to "Micronaut" in this generic extension
* @param dbconn | ||
* @return List of schemas or null if connection failed | ||
*/ | ||
public List<String> getSchemas(DatabaseConnection dbconn) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an API change. It needs @since
tag, it needs a note in apichanges.xml
.
*/ | ||
public List<String> getSchemas(DatabaseConnection dbconn) { | ||
if (SwingUtilities.isEventDispatchThread()) { | ||
throw new IllegalStateException("This method can not be called on the event dispatch thread."); // NOI18N |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cannot is a single word - maybe you want to spell this (unusual?) restriction in the Javadoc of the method.
* Retrieves a list of database schemas available for given connection. | ||
* | ||
* @param dbconn | ||
* @return List of schemas or null if connection failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually use {@code null}
to print it in a different font. Shouldn't an exception be raised if the connection fails?
} | ||
} | ||
} | ||
} catch (DatabaseException | SQLException ex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not propagate the exception to the caller?
org.openide.options,\ | ||
org.openide.util.enumerations,\ | ||
org.openidex.util | ||
nbjdk.active=JDK_11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid nbjdk.active
and nbplatform.active
.
@@ -858,6 +859,7 @@ protected LanguageClient client() { | |||
public static final String JAVA_SUPER_IMPLEMENTATION = "java.super.implementation"; | |||
public static final String JAVA_SOURCE_FOR = "java.source.for"; | |||
public static final String GRAALVM_PAUSE_SCRIPT = "graalvm.pause.script"; | |||
public static final String DB_ADD_CONNECTION = "micronaut.add.db.connection"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this command prefixed by micronaut
? The DB explorer is completely micronaut unrelated, right?
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/ShowInputBoxParams.java
Show resolved
Hide resolved
{ | ||
"command": "micronaut.add.db.connection", | ||
"title": "Add Database Connection", | ||
"category": "Micronaut" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be better if Micronaut extension were in enterprise/micronaut
module, not here.
ide/db/src/org/netbeans/modules/db/explorer/DbSchemasQuery.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most recent version eliminates the API changes altogether, great! The "Add Database Connection" command looks fine to me. Please squash a bit to eliminate the add/remove of platform.properties
entries and the API attempt from the history after merge.
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/db/DatabaseCommands.java
Outdated
Show resolved
Hide resolved
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/db/DatabaseCommands.java
Outdated
Show resolved
Hide resolved
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/db/DatabaseCommands.java
Outdated
Show resolved
Hide resolved
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/db/DatabaseCommands.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates, looks sane to me.
@jhorvath Before this is merged:
|
|
4d43197
to
28a654a
Compare
FileObject jarFO = URLMapper.findFileObject(jars[0]); | ||
if (jarFO != null && jarFO.isValid()) { | ||
items.add( | ||
new QuickPickItem(drivers[i].getName(), null, drivers[i].getDisplayName() + " (" + drivers[i].getClassName() + ")", false, i) // NOI18N |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm; on the second thought, consider to send drivers[i].getName()
to identify the selected driver in then
clause. Not necessary, unless another vscode
instance adds a driver.
} | ||
client.showInputBox(new ShowInputBoxParams( | ||
Bundle.MSG_EnterPassword(), "", true)).thenAccept((password) -> { //NOI18N | ||
if (password == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is password required for all databases ? E.g. for mysql
, password-less logins can be allowed (?)
return; | ||
} | ||
DatabaseConnection dbconn = DatabaseConnection.create(driver, u, username, null, password, true); | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you would like to limit that deep nesting, this is the point where the CompletableFuture
can yield a DatabaseConnection
instance and we can with thenAccept
at top level again :)
ResultSet rs = dbMetaData.getSchemas(); | ||
if (rs != null) { | ||
while (rs.next()) { | ||
schemas.add(rs.getString(1).trim()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is index safer than column name in this case ?
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/Server.java
Outdated
Show resolved
Hide resolved
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/ShowInputBoxParams.java
Show resolved
Hide resolved
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/ShowInputBoxParams.java
Outdated
Show resolved
Hide resolved
@@ -756,7 +756,7 @@ function doActivateWithJDK(specifiedJDK: string | null, context: ExtensionContex | |||
return selected ? Array.isArray(selected) ? selected : [selected] : undefined; | |||
}); | |||
c.onRequest(InputBoxRequest.type, async param => { | |||
return await window.showInputBox({ prompt: param.prompt, value: param.value }); | |||
return await window.showInputBox({ prompt: param.prompt, value: param.value, password: param.password }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump required spec version in nbcode/integration
module.
…d java.lsp.server version
I would ignore the commit validation on Mac. Failed on a timeout. |
Adding command for New Database Connection to java.lsp.server