ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/trunk/tools/QueryThread.java
Revision: 492
Committed: Wed Jan 2 13:18:57 2008 UTC (16 years, 10 months ago) by duarte
File size: 1061 byte(s)
Log Message:
Copied the aglappe-jung branch into trunk.

Line File contents
1 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 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 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 *