I am facing the following problem: I want to drag'n drop a database table node from the "Database Structure" view to my own view and be able to obtain some information about the database table that has been dropped, e.g. connection URL, username, password, etc. I've managed to get some of those with the following code (which is invoked after a db table node is dropped).
The information that I am not able to "find" is the driver being used (driver name, driver class and , if possible, the jar/zip containing the driver). So is it possible to get these informations in some similar way? I am using "3.5.0.RC5" release. Thanks in advance.
Jakub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Session session = ((TableNode)selection).getSession();
User user = session.getUser();
Alias alias = user.getAlias();
ManagedDriver driver = alias.getDriver();
LinkedList<String> jars = driver.getJars();
String driverClassName = driver.getDriverClassName();
java.sql.Driver jdbcDriver = driver.getJdbcDriver();
String jdbcUrl = driver.getUrl();
A Session represents an active connection to a database, where that connection is established with a given set of User credentials. User credentials are specific to a given Alias, and an Alias is specific to a given ManagedDriver. Inversely, a ManagedDriver has multiple Alias's, an Alias has multiple User's, and a User has multiple Session's.
If an Alias has one or more User's, then one of them will be the "default" user; where a database does not support user credentials (eg Excel ODBC) then Alias.hasNoUserName() returns true and the Alias will only one User and that User will have a username of "anonymous" and an empty string for a password.
John
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
I am facing the following problem: I want to drag'n drop a database table node from the "Database Structure" view to my own view and be able to obtain some information about the database table that has been dropped, e.g. connection URL, username, password, etc. I've managed to get some of those with the following code (which is invoked after a db table node is dropped).
import net.sourceforge.sqlexplorer.plugin.views.TableNodeTransfer;
import net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode;
import net.sourceforge.sqlexplorer.dbproduct.Session;
public String getUserPassword()
{
TableNodeTransfer tableNodeTransfer = TableNodeTransfer.getInstance();
Object selection = tableNodeTransfer.getSelection();
if ( !( selection instanceof TableNode ))
return null;
Session session = ((TableNode)selection).getSession();
return session.getUser().getPassword();
}
, etc...
The information that I am not able to "find" is the driver being used (driver name, driver class and , if possible, the jar/zip containing the driver). So is it possible to get these informations in some similar way? I am using "3.5.0.RC5" release. Thanks in advance.
Jakub
Session session = ((TableNode)selection).getSession();
User user = session.getUser();
Alias alias = user.getAlias();
ManagedDriver driver = alias.getDriver();
LinkedList<String> jars = driver.getJars();
String driverClassName = driver.getDriverClassName();
java.sql.Driver jdbcDriver = driver.getJdbcDriver();
String jdbcUrl = driver.getUrl();
A Session represents an active connection to a database, where that connection is established with a given set of User credentials. User credentials are specific to a given Alias, and an Alias is specific to a given ManagedDriver. Inversely, a ManagedDriver has multiple Alias's, an Alias has multiple User's, and a User has multiple Session's.
If an Alias has one or more User's, then one of them will be the "default" user; where a database does not support user credentials (eg Excel ODBC) then Alias.hasNoUserName() returns true and the Alias will only one User and that User will have a username of "anonymous" and an empty string for a password.
John