grover_mickey

Greenhorn
+ Follow
since Jun 27, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by grover_mickey

hello guys,
i am calling method of a class Two(extending JFrame) from within
constructor Class One(implementing Runnable)
steps:
1.i made the object of class two in a thread in class one and calls a method of it there in run.ex:thread.run() in one()//constructor
2.now,i call same method of class two,thsi time in constructor
one() after i call thread.run() in one()but it is giving null pointer exception
i also used thread.join() but doing that the two loses it's component and shows empty frame.
my coding is
mport java.util.*;
import java.sql.*;
import java.awt.*;
public class One implements Runnable
{ public Thread thread=new Thread(this);

public Process p;
public Logout logout;
public String Login_Name,Time_db,login_time;

public One(String str1,String str2,String str3) //name,time,client_machine
{
//Runtime r=Runtime.getRuntime();
//Process p=null;
Convert one;
//Thread thread;
int Time_db_hr,Time_db_min,current_hr,current_min,check_time_hr,check_time_min,alarm_hr,alarm_min;
String current_time,alarm_time,check_time,updated_time_bought,updated_time_bought_hr,updated_time_bought_min,str2_hr,str2_min;
StringTokenizer st1,st2,st3,st4;
Connection con;
Statement stmt=null,stmt2=null,stmt3=null,stmt4=null;
ResultSet result=null,result2=null;
String sql1,sql2,sql3;
boolean bool=true;
Current_Time systime;
Login_Name=str1;
String guest="guest";
String switching_time;
//Logout logout;
//thread=new Thread(this);
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("Jdbc:Odbc:userdsn","scott","tiger");

if((str2.compareTo("00:00"))!=0)
{
one=new Convert();
Time_db=one.con(str2);//postclocktime

//switching_time=Time_db;

st1=new StringTokenizer(Time_db,":");
Time_db_hr=Integer.parseInt(st1.nextToken());
Time_db_min=Integer.parseInt(st1.nextToken());
System.out.println("time in execdemo"+Time_db);
//p=r.exec("c:\\Program Files\\Internet Explorer\\IEXPLORE.exe");
System.out.println("After explorer");
systime=new Current_Time();
current_time=systime.current_time_fun();

login_time=current_time;


thread.start();
System.out.println("thread is"+Thread.currentThread()+thread);
System.out.println("logintime= "+login_time+" Switching Time= "+Time_db);

//try{p=logout.LogoutFunction(login_time,Time_db);}catch(Exception e){System.out.println("pakar"+e);}
switching_time=Time_db;
System.out.println("back to exedemo");

st4=new StringTokenizer(current_time,":");
current_hr=Integer.parseInt(st4.nextToken());
current_min=Integer.parseInt(st4.nextToken());

if(current_min<=9)<br /> {<br /> current_time=current_hr+":0"+current_min;<br /> }<br /> else<br /> {<br /> current_time=current_hr+":"+current_min;<br /> }<br /> <br /> <br /> <br /> <br /> while (!(current_time.equals(Time_db)))<br /> { <br /> System.out.println("deepak"); <br /> //try{<br /> p=logout.LogoutFunction(login_time,Time_db);<br /> <br /> // }catch(Exception e){System.out.println("CAUGHT:->"+e);}
System.out.println("switching off time "+Time_db);
Thread.sleep(1000);
current_time=systime.current_time_fun();
st4=new StringTokenizer(current_time,":");
current_hr=Integer.parseInt(st4.nextToken());
current_min=Integer.parseInt(st4.nextToken());

if(current_min<=9)<br /> {<br /> current_time=current_hr+":0"+current_min;<br /> }<br /> else<br /> {<br /> current_time=current_hr+":"+current_min;<br /> }<br /> System.out.print("\ncurrent time"+current_time);<br /> <br /> if(Time_db_min>=10)
{
alarm_min=Time_db_min-10;
alarm_hr=Time_db_hr;
}

else
{
alarm_hr=Time_db_hr-1;
alarm_min=Time_db_min+50;
}

if(alarm_min<=9)<br /> {<br /> alarm_time=alarm_hr+":0"+alarm_min;<br /> }<br /> else<br /> {<br /> alarm_time=alarm_hr+":"+alarm_min;<br /> }<br /> System.out.print(" alarm time"+alarm_time);<br /> <br /> <br /> if((current_time.equals(alarm_time))&& bool)<br /> {<br /> // Dialog box<br /> new AlarmDialog(new Frame());<br /> bool=false;<br /> }<br /> <br /> if(Time_db_min>=5)
{
check_time_min=Time_db_min-5;
check_time_hr=Time_db_hr;
}
else
{
check_time_hr=Time_db_hr-1;
check_time_min=Time_db_min+55;
}
if(check_time_min<=9)<br /> {<br /> check_time=check_time_hr+":0"+check_time_min;<br /> }<br /> else<br /> {<br /> check_time=check_time_hr+":"+check_time_min;<br /> }<br /> System.out.print(" check time"+check_time);<br /> <br /> if(current_time.equals(check_time))<br /> {<br /> <br /> stmt=con.createStatement();<br /> <br /> if(str1.equals(guest))<br /> {<br /> sql1="select Time_Bought from welcome where Machine_No='"+str3+"';"; <br /> System.out.println("in guest");<br /> result=stmt.executeQuery(sql1);<br /> boolean b=result.next();<br /> updated_time_bought=result.getString("Time_Bought");<br /> }<br /> else<br /> {<br /> sql1="select * from database where Login_Name='"+str1+"';";<br /> System.out.println("in registered");<br /> result=stmt.executeQuery(sql1);<br /> boolean b=result.next();<br /> updated_time_bought=result.getString("Total_Time_Remaining");<br /> } <br /> /***********************************/<br /> System.out.println("hurrayhurray!!!"+updated_time_bought);<br /> /**********************************/<br /> st2=new StringTokenizer(str2,":");<br /> st3=new StringTokenizer(updated_time_bought,":");<br /> str2_hr=st2.nextToken();<br /> str2_min=st2.nextToken();<br /> updated_time_bought_hr=st3.nextToken();<br /> updated_time_bought_min=st3.nextToken();<br /> <br /> int time_bought_hr=Integer.parseInt(updated_time_bought_hr)-Integer.parseInt(str2_hr);<br /> int time_bought_min;<br /> <br /> if(Integer.parseInt(updated_time_bought_min)>=Integer.parseInt(str2_min))
{
time_bought_min=Integer.parseInt(updated_time_bought_min)-Integer.parseInt(str2_min);
}
else
{
time_bought_min=Integer.parseInt(updated_time_bought_min)-Integer.parseInt(str2_min)+60;
time_bought_hr-=1;
}

Time_db_hr+=time_bought_hr;
Time_db_min+=time_bought_min;
if(Time_db_min>=60)
{
Time_db_min-=60;
Time_db_hr+=1;
}
if(Time_db_min<10)
{
Time_db=Time_db_hr+":0"+Time_db_min;
}
else
{
Time_db=Time_db_hr+":"+Time_db_min;
}
str2=updated_time_bought;

}
}
//destroy the browser,do necessary updations
p.destroy();
System.out.println("process destroyed");
if(!(str1.equals(guest)))
{
try{
AddTime two=new AddTime();
String sql9="select * from database where Login_Name='"+str1+"';";
System.out.println("in registered");
stmt2=con.createStatement();

result2=stmt2.executeQuery(sql9);
boolean b=result2.next();
System.out.println(sql9);
String TTA=result2.getString("Total_Time_Accessed");
System.out.println(TTA);
String total_time_accessed=two.con(TTA,str2);
sql2="update database set Total_Time_Remaining='00:00',Total_Time_Accessed='"+total_time_accessed+"' where Login_Name='"+str1+"';";
System.out.println(sql2);

stmt4=con.createStatement();
int i=stmt4.executeUpdate(sql2);
}catch(Exception e){System.out.println("HELLO"+e);}
}
sql3="delete welcome where Machine_No='"+str3+"';";
stmt3=con.createStatement();
int i=stmt3.executeUpdate(sql3);
logout.dispose();
new New();
}
}catch (Exception e)
{
System.out.println("Error Executing Notepad: "+e);
}
}
public void run()
{
if(Thread.currentThread()==thread)
{
logout=new Logout(Login_Name);
System.out.println("before function");
p=logout.LogoutFunction(login_time,Time_db);
System.out.println("after function");
thread.stop();
}
}
}

plz do help me.it's a matter of life/death
amit
hello guys,
plz do help me for my very existence.my prob is
1.how to disable <ctrl> key using java application
2.how to kill all internet explorers running
plz reply soon
amit
22 years ago