I have a Solaris script that I use to connect to SQLPlus. At the end of this script, I am given the SQL>
prompt. The script looks like this:
`#!/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`
Now, I a trying to create a java swing UI with a button on it, clicking which will execute this script in the background and I should get the same SQL>
prompt. The swing code looks like this:
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);
}
});
}
But when I execute this code, I obviously do not get the SQL prompt. What can I do to get the prompt?