Iam not very clear with your question... my understanding is, you want to connect to the db using DSN (which has userid and password given) and then later get the username in your code after getting connected.
For this, you have to connect using the syntax:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String dsn = "DSN_NAME";
String url = "jdbc
dbc:" + dsn;
Connection con = DriverManager.getConnection(url); To get the username in your program after getting connected to the db, you can use
getUserName() of
DatabaseMetaData interface.
Hope this is what you wanted...