我无法尝试让tnsname.ora文件执行以下操作:
I managed to get the JComboBox populated with the data from the service_name
My next question is the following:
一个。如果在JCombobox上选择了特定的service_name,如何填充CORRECT /适当的主机名(例如127.0.0.3)。
我。我知道这可以使用itemStateChanged(ItemEvent ie)完成,并且我可以使其动作,以便在选择不同的服务名称时填充数据。但问题是,如何做以下几点:
If the service_name equals a certain SID
一个。然后去填充存储的文本框:
我。宿主
II。端口
III。协议
我有自己的理论如何做到这一点,但不知道如何将其转换为Java代码:
public void PopulateTnsNamesDropDownList() {
Properties prop = new Properties();
InputStream input2 = null;
try {
input2 = new FileInputStream("C:\\folder\\config.properties");
try {
prop.load(input2);
} catch (IOException e) {
e.printStackTrace();
}
String path = null;
path = prop.getProperty("tnsnames_directory");
BufferedReader input = new BufferedReader(new FileReader(path));
List<String> strings = new ArrayList<String>();
try {
String line = null;
try {
while ((line = input.readLine()) != null) {
if (line.contains("(SERVICE_NAME =")) {
String service_name = null;
service_name = line.replaceAll("SERVICE_NAME = ", "").trim().replaceAll("\\(", "").replaceAll("\\)", "");
strings.add(service_name);
}
}
} catch (IOException e) {
JOptionPane.showMessageDialog(Workers.this, "Error, configuration properties did not exist or not set correctly." + e.getMessage());
}
}
finally {
try {
input.close();
} catch (IOException e) {
JOptionPane.showMessageDialog(Workers.this, "Error, configuration properties did not exist or not set correctly." + e.getMessage());
}
}
String[] lineArray = strings.toArray(new String[] {});
JComboBox comboBox = new JComboBox(lineArray);
TnsNamesComboBox.setModel(new javax.swing.DefaultComboBoxModel(lineArray));
} catch (FileNotFoundException e) {
JOptionPane.showMessageDialog(Workers.this, "Error, configuration properties did not exist or not set correctly." + e.getMessage());
}
}