Hola jhonmelguizo,
Intenta con este codigo:
package obdc;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
public class OdbcSystemDSNListUtil {
public static Set getODBCSystemDNS() {
String PERSONAL_FOLDER_CMD =
"HKEY_LOCAL_MACHINE\\SOFTWARE\\ODBC\\ODBC.INI" ;
String[] command =
new String[] { "reg", "query", PERSONAL_FOLDER_CMD };
Set dsnList = new HashSet();
try {
Process process = Runtime.getRuntime().exec(command);
BufferedReader stream =
new BufferedReader(new InputStreamReader(process.getInputStream()));
String dsn = "";
while ((dsn = stream.readLine()) != null) {
if (dsn.indexOf(PERSONAL_FOLDER_CMD + "\\") != -1)
dsnList.add(dsn.substring(dsn.lastIndexOf("\\") + 1));
}
} catch (IOException e) {
e.printStackTrace();
}
return dsnList;
}
public static void main(String[] args) {
Set dsnList = getODBCSystemDNS();
for (Object dsn: dsnList) {
System.out.println("dsn name: " + dsn);
}
}
}
Cualquier cosa estoy en el sgte correo:
[email protected]
Saludos
Manuel