|
Hi everyone,
Thanks to Yogesh and Stephen Raj Arokiasamy for the
quick response but the problem still persists.I am using a system dsn called
mjs.
At compile time there r no errors only 1 warning
but as soon as I run this code it hangs.I agree that I have not added a window
listener nut the system.exit(1) sould at least allow me to exit.
Please do help,
Thanks in advance,
MJS
import java.sql.*;
import java.awt.*; import java.awt.event.*; import java.util.*; import sun.jdbc.odbc.JdbcOdbcDriver; public class nayausr extends Frame implements
ActionListener
{ String temp,temp1,temp2; static Connection con; public static void main(String s[]) { nayausr t=new nayausr(); t.setLayout(new FlowLayout()); t.setSize(500,500); t.create(t); } public void create(nayausr f)
{ Label lbel=new Label("Please enter new user details"); Label lb=new Label(" "); Label l1=new Label("Username : "); TextField t1=new TextField(20); Label l2=new Label(" Password : "); TextField t2=new TextField(20); Label l3=new Label(" Employee number : "); TextField t3=new TextField(20); t2.setEchoCharacter('*'); Label lb1=new Label(" "); Button b=new
Button();
b.setLabel("SUBMIT"); b.addActionListener(f); f.add(lbel); f.add(l1); f.add(t1); f.add(lb); f.add(l2); f.add(t2); f.add(lb1); f.add(l3); f.add(t3); f.add(b);
temp =t1.getText();
temp1 =t3.getText(); f.setVisible(true);
} public void actionPerformed(ActionEvent
e)
{ String s=e.getActionCommand(); if (s.equals("SUBMIT")) { Db(temp,temp1); } } public void Db(String te1,String
te2)
{ String url="jdbc:odbc:mjs"; try { try {Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");} catch (Exception e){} con=DriverManager.getConnection(url,"",""); Statement s1=con.createStatement();
String qq="INSERT INTO abc VALUES('"+"'"+te1+"','"
+te2+"'
)";
s1.executeUpdate(qq); System.exit(1); System.out.println("INSERTED SUCCESSFULLY " ); s1.close();
con.close(); } catch(SQLException e)
{ }
finally { try {con.close(); } catch (Exception w){} } }
}
|
- Re: STILL NO LUCK! MJS MJS
- Re: STILL NO LUCK! Paresh Gheewala
- Re: STILL NO LUCK! Kiran
- Re: STILL NO LUCK! Nic Ferrier
- Re: STILL NO LUCK! Rashid Amin
- Re: STILL NO LUCK! Kiran
