我有一个用于连接 SQLPlus 的 Solaris 脚本。在这个脚本的结尾,我得到了SQL>
提示。脚本如下所示:
`#!/bin/ksh
echo Setting ORACLE_HOME ..
export ORACLE_HOME=<path>
echo Setting ORACLE_SID ..
export ORACLE_SID=<SID>
echo Setting PATH ..
export PATH=$PATH:$ORACLE_HOME/bin
echo
echo Connecting to SQLPlus ..
$ORACLE_HOME/bin/sqlplus pdmlink80/pd1016I65@P38`
现在,我试图创建一个带有按钮的 java swing UI,单击它将在后台执行此脚本,我应该得到相同的SQL>
提示。摆动代码如下所示:
public class ButtonExample extends JFrame {
public ButtonExample() {
initUI();
}
private void initUI() {
JPanel panel = new JPanel();
getContentPane().add(panel);
panel.setLayout(null);
JButton myButton = new JButton("Button");
myButton.setBounds(50, 60, 80, 30);
myButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
String s;
Process p;
try {
p = Runtime.getRuntime().exec("/usr1/ptc/Windchill_9.1/Windchill/bin/windchill shell");
p.waitFor();
BufferedReader br = new BufferedReader(
new InputStreamReader(p.getInputStream()));
while ((s = br.readLine()) != null){
System.out.println(s);
break;
}
System.out.println ("exit: " + p.exitValue());
JOptionPane.showMessageDialog(null,"Script successfully executed!!");
}
catch (Exception e) {}
}
});
panel.add(myButton);
setTitle("ButtonExample");
setSize(300, 200);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
ButtonExample ex = new ButtonExample();
ex.setVisible(true);
}
});
}
但是当我执行这段代码时,我显然没有得到 SQL 提示。我该怎么做才能得到提示?