svn-gvsig-desktop / trunk / libraries / libJCRS / src / org / gvsig / crs / EpsgConnection.java @ 8500
History | View | Annotate | Download (1.19 KB)
1 |
package org.gvsig.crs; |
---|---|
2 |
|
3 |
import java.sql.Connection; |
4 |
import java.sql.DriverManager; |
5 |
import java.sql.SQLException; |
6 |
import java.sql.Statement; |
7 |
|
8 |
public class EpsgConnection { |
9 |
|
10 |
Connection connect;
|
11 |
|
12 |
public EpsgConnection() {
|
13 |
try {
|
14 |
Class.forName("org.hsqldb.jdbcDriver"); |
15 |
} catch (ClassNotFoundException e) { |
16 |
e.printStackTrace(); |
17 |
} |
18 |
} |
19 |
|
20 |
public void setConnectionEPSG() { |
21 |
try {
|
22 |
connect = DriverManager.getConnection("jdbc:hsqldb:file:gvSIG/extensiones/org.gvsig.crs/db_epsg", "sa", ""); |
23 |
} catch (SQLException e1) { |
24 |
e1.printStackTrace(); |
25 |
} |
26 |
} |
27 |
|
28 |
public void setConnectionIAU2000() { |
29 |
try {
|
30 |
connect = DriverManager.getConnection("jdbc:hsqldb:file:gvSIG/extensiones/org.gvsig.crs/db_iau2000", "sa", ""); |
31 |
} catch (SQLException e1) { |
32 |
e1.printStackTrace(); |
33 |
} |
34 |
} |
35 |
|
36 |
public Connection getConnection(){ |
37 |
return connect;
|
38 |
} |
39 |
|
40 |
public void shutdown() throws SQLException { |
41 |
|
42 |
Statement st = connect.createStatement();
|
43 |
|
44 |
// db writes out to files and performs clean shuts down
|
45 |
// otherwise there will be an unclean shutdown
|
46 |
// when program ends
|
47 |
st.execute("SHUTDOWN");
|
48 |
connect.close(); // if there are no other open connection
|
49 |
} |
50 |
} |