FingerPrint_5.2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
package test;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.FileReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Date;
import java.util.Properties;
import java.util.Vector;
public class Utilities {
Connection con;
FileReader reader;
String mysql_driver_string="";
String mysql_connection_string="";
String mysql_username="";
String mysql_password="";
String query ="";
public Utilities() {
this.con = getConnection();
}
public Connection getConnection(){
try {
reader = new FileReader("config.properties");
Properties properties=new Properties();
properties.load(reader);
String mysql_driver_string=properties.getProperty("mysql_driver_string");
String mysql_connection_string=properties.getProperty("mysql_connection_string");
String mysql_username=properties.getProperty("mysql_username");
String mysql_password=properties.getProperty("mysql_password");
//System.out.println("mysql_driver_string: "+mysql_driver_string+"\nmysql_connection_string: "+mysql_connection_string+"\nmysql_username: "+mysql_username+"\nmysql_password: "+mysql_password);
this.mysql_driver_string = mysql_driver_string;
this.mysql_connection_string = mysql_connection_string;
this.mysql_username = mysql_username;
this.mysql_password = mysql_password;
Class.forName(mysql_driver_string).newInstance();
Connection con = DriverManager.getConnection(mysql_connection_string, mysql_username, mysql_password);
System.out.println("-- connect --");
this.con = con;
} catch (Exception e) {e.printStackTrace();}
return con;
}
public Connection getConnection_remote(){
try {
reader = new FileReader("config.properties");
Properties properties=new Properties();
properties.load(reader);
String mysql_driver_string=properties.getProperty("mysql_driver_string");
String mysql_connection_string=properties.getProperty("mysql_connection_string_remote");
String mysql_username=properties.getProperty("mysql_username_remote");
String mysql_password=properties.getProperty("mysql_password_remote");
//System.out.println("mysql_driver_string: "+mysql_driver_string+"\nmysql_connection_string: "+mysql_connection_string+"\nmysql_username: "+mysql_username+"\nmysql_password: "+mysql_password);
this.mysql_driver_string = mysql_driver_string;
this.mysql_connection_string = mysql_connection_string;
this.mysql_username = mysql_username;
this.mysql_password = mysql_password;
Class.forName(mysql_driver_string).newInstance();
Connection con = DriverManager.getConnection(mysql_connection_string, mysql_username, mysql_password);
System.out.println("-- connect --");
this.con = con;
} catch (Exception e) {e.printStackTrace();}
return con;
}
public void closeConnection(Connection con) {
try {
con.close();
} catch (Exception e) {e.printStackTrace();}
}
public Vector selectQuery(String query, int params, Connection con){
Vector result = new Vector();
try {
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(query);
while (rs.next()) {
Vector temp = new Vector();
for (int i = 1; i <= params; i++) {
String str = (String) rs.getString(i);
temp.add(str);
}
result.add(temp);
}
} catch (Exception e) {e.printStackTrace();}
return result;
}
public String getField(String query, Connection con){
String result = "";
try {
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(query);
while (rs.next()) {
result = (String) rs.getString(1);
}
} catch (Exception e) {e.printStackTrace();}
return result;
}
public void insertQuery(String query, Connection con){
try {
Statement st = con.createStatement();
int ins = st.executeUpdate(query);
System.out.println(" >> ins: "+ins);
} catch (Exception e) {e.printStackTrace();}
}
public Dimension getScreenDimension(){
int screen_width = (int)Toolkit.getDefaultToolkit().getScreenSize().getWidth();
int screen_height = (int)Toolkit.getDefaultToolkit().getScreenSize().getHeight();
//System.out.println("####Screen width: "+screen_width+" screen_height: "+screen_height);
Dimension screen_dimension = new Dimension(screen_width, screen_height);
return screen_dimension;
}
}
|
Revision |
Author |
Commited |
Message |
1
|
lingaraj
|
Sat 24 Nov, 2018 09:32:39 +0000 |
|