ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/trunk/tools/QueryThread.java
Revision: 97
Committed: Fri Jun 2 09:49:54 2006 UTC (18 years, 4 months ago) by duarte
File size: 1061 byte(s)
Log Message:
Added getters/setters to host,db,user and password in MySQLConnection
Added another constructor to QueryThread to take just the MySQLConnection as argument
Line User Rev File contents
1 duarte 86 package tools;
2    
3     import java.sql.SQLException;
4    
5     public class QueryThread extends Thread {
6    
7     String query;
8     String host;
9     String user;
10     String pwd;
11     String db;
12    
13     public QueryThread(String query, String host, String user, String pwd, String db){
14     this.query = query;
15     this.host = host;
16     this.user = user;
17     this.pwd = pwd;
18     this.db = db;
19     start();
20     }
21    
22 duarte 97 public QueryThread(String query, MySQLConnection conn){
23     this.query = query;
24     this.host = conn.getHost();
25     this.user = conn.getUser();
26     this.pwd = conn.getPassword();
27     this.db = conn.getDbname();
28     start();
29     }
30    
31 duarte 86 public void run(){
32     try {
33     long start = System.currentTimeMillis();
34     MySQLConnection conn = new MySQLConnection(host,user,pwd,db);
35     conn.executeSql(query);
36     conn.close();
37     long end = System.currentTimeMillis();
38     System.out.println("Executed QUERY="+query+" DB="+db+", HOST="+host+". Time was: "+(end-start)/1000+" seconds.");
39     }
40     catch(SQLException e){
41     e.printStackTrace();
42     System.err.println("Couldn't execute QUERY="+query+" DB="+db+", HOST="+host);
43     }
44     }
45    
46     }

Properties

Name Value
svn:executable *