Comments (3)
So you want to use multiple user/pw with one SQLDev Connection? Do I understand correctly or would multiple (java.sql) connections via the same credentials work?
What problem is the extension meant to solve? Throwing script(s) at a bunch of connections would seem more a scripting thing you could do with sqlcl to me but I don't know your context.
Note that SQLDev Connections are identified by {store name}%{connection name} and define a {user}+[{password}+]{connection driver info e.g. host,port,sid/service[,role], etc. for Oracle DB}
That said, there are utility functions for getting unique (java.sql) connections for a given SQLDeveloper connection and also for creating a SQLDev Connection for a new user/pw based on an existing one. E.g.,
for (String qualifiedConnectionName : ConnectionResolver.getConnectionNames()) {
// Get shared connection for qualified name (this is the one SQLDeveloper uses for the navigator and displays)
java.sql.Connection sharedConn = ConnectionResolver.getConnection(qualifiedConnectionName);
// Get unique (unnamed) connection using credentials from qualifiedConnectionName
java.sql.Connection uniqueConn = ConnectionResolver.getUniqueConnection(qualifiedConnectionName);
// Get new connection for name/pw using connection driver info from qualifiedConnectionName
String folderName = null; // Will use "Connections based on " + qualifiedConnectionName if null
String username = "someUser"; // Must be unique as it will be used as the connection name
String password = "somePassword";
ConnectionUtils.addNewConnectionBasedOn(folderName, qualifiedConnectionName, username, password);
String newConnQualifiedName = ConnectionResolver.getQualifiedConnectionName(username);
java.sql.Connection newConn = ConnectionResolver.getConnection(newConnQualifiedName);
java.sql.Connection myConn = newConn; // or uniqueConn
String displayName = ConnectionResolver.getConnectionName(myConn); // null for uniqueConn(s)
// do stuff ...
// See if one of the DBUtil.getInstance(myConn).execute... methods work for you - it handles locking/error reporting
// if using newConn, close and remove sqldev connection
Connections.close(newConnQualifiedName);
(*%%$ I'm going to have to add some way for extensions to programmatically delete the connection to sqldev itself. (19.4 hopefully)
from oracle-db-examples.
Added utility functions for 19.4. Example usage creating, openening, and setting up to close(if needed)+delete the new connection when sqldeveloper exits:
Given a (fully qualified) connectionName for an existing connection
SwingUtilities.invokeLater(() -> {
final String folder = "Testing";
final String user = "someUser"; // Must be unique as it will be used as the connection name
final String pw = "somePassword";
ConnectionUtils.addNewConnectionBasedOn(folder, connectionName, user, pw);
final String fqName = ConnectionUtils.getFqConnectionName(user);
ConnectionUtils.connect(fqName);
ExitCommand.addShutdownHook(new ShutdownHook() {
@Override
public boolean canShutdown() {
return true;
}
@Override
public void shutdown() {
ConnectionUtils.closeAndDeleteConnection(fqName);
}
});
});
from oracle-db-examples.
No response to the answer in a month. Assuming it is OK or user no longer cares. Closing.
from oracle-db-examples.
Related Issues (20)
- Error: ORA-00904: "EMPLOYEE_ID": invalid identifier HOT 2
- [Connection Helper] Service name with dot not working HOT 1
- Connect oracle cloud with ojdbc6, jdk1.7.0_80 HOT 1
- SQL Developer Extension Connection/Struct Issue HOT 5
- java.sql.SQLRecoverableException: IO Error: Unknown host specified when trying to start a springboot project HOT 2
- Update JDBC samples
- (SQLDeveloper) Improve error reporting for ConnectionHelperClient HOT 1
- https://jsao.io/ is down? HOT 3
- ConnectionHelper Settings Ignored if a Connection with that Name Exists HOT 2
- Connection Helper Error HOT 2
- I/O Error
- Exadata Real Time Insight actual tutorials HOT 1
- How to enter connection string in prompt? HOT 1
- SQL Developer: Dependencies - Arrow with strange orientation HOT 1
- How to create a view that fetches all records from a jdbc connection? HOT 2
- Add code and configuration examples for continuous application availability
- Prometheus scrape configuration to get real-time insight metrics into Prometheus HOT 1
- OracleStatementWrapper add setLocalInfileInputStream Method
- jdbc sample context.xml missing quote HOT 2
- EF Core invalid generated query HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oracle-db-examples.