Revision 8146 trunk/libraries/libJCRS/src/org/gvsig/crs/Query.java
Query.java | ||
---|---|---|
4 | 4 |
import java.io.Serializable; |
5 | 5 |
import java.sql.Connection; |
6 | 6 |
import java.sql.ResultSet; |
7 |
import java.sql.ResultSetMetaData; |
|
7 | 8 |
import java.sql.SQLException; |
8 | 9 |
import java.sql.Statement; |
9 | 10 |
|
10 | 11 |
public class Query implements Serializable{ |
11 | 12 |
|
13 |
/** |
|
14 |
* |
|
15 |
*/ |
|
16 |
private static final long serialVersionUID = 1L; |
|
17 |
|
|
12 | 18 |
public static synchronized ResultSet select(String sentence, Connection conn){ |
13 | 19 |
Statement st = null; |
14 | 20 |
ResultSet rs = null; |
15 |
|
|
16 |
|
|
21 |
|
|
17 | 22 |
try { |
18 | 23 |
st = conn.createStatement(); |
19 | 24 |
rs = st.executeQuery(sentence); |
25 |
st.close(); |
|
20 | 26 |
} catch (SQLException e) { |
21 | 27 |
e.printStackTrace(); |
22 |
} |
|
23 |
|
|
28 |
} |
|
24 | 29 |
return rs; |
25 |
} |
|
26 |
|
|
27 |
/*public static synchronized ResultSet query(String expression, Connection conn) throws SQLException { |
|
28 |
|
|
29 |
Statement st = null; |
|
30 |
ResultSet rs = null; |
|
31 |
|
|
32 |
st = conn.createStatement(); // statement objects can be reused with |
|
33 |
|
|
34 |
// repeated calls to execute but we |
|
35 |
// choose to make a new one each time |
|
36 |
rs = st.executeQuery(expression); // run the query |
|
37 |
|
|
38 |
return rs; |
|
39 |
}*/ |
|
40 |
|
|
30 |
} |
|
41 | 31 |
} |
42 | 32 |
|
Also available in: Unified diff