Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

acess problems  RSS feed

 
sumi essakiappan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

hi all,

in the program thge values of JLabel ll and txt are getting lost in the
getcon() function ...i think some problem with acess control...
kindly guide.

import java.sql.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class deldr extends JFrame implements ActionListener
{
ResultSet rs;
Connection con;
Statement s1;
public JLabel ll;
public String st;
public JTextField txt;
JPanel pp;
public deldr()
{
System.out.println("hello");
JLabel ll= new JLabel("enter the doctor name");
JTextField txt=new JTextField(30);
//System.out.println(txt);
txt.setActionCommand("txt");
txt.addActionListener(this);
JPanel pp=new JPanel();
pp.add(ll);
pp.add(txt);
getContentPane().add(pp);
setSize(600,700);
show();
//System.out.println(ll);
}

public void getcon()
{
System.out.println(ll);
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc dbc gcora","m98a28","m98a28");
s1=con.createStatement();
System.out.println(ll);
System.out.println("hello");
}catch(Exception e){}
}

public void del()
{
getcon();
//String ll=txt.getText().trim();

String query="delete from doctors where name="+"'"+ll+"'";
System.out.println("hello1");
try
{
//s1.executeUpdate(query);
//con.commit();
}catch(Exception e){}
}
public void actionPerformed(ActionEvent e)
{
String str;
str=e.getActionCommand();
if(str.equals("txt"))
{
del();
}
}
public static void main(String args[])
{
deldr d= new deldr();
}
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!