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
| import java.sql.*;
public class vesselDistance {
/**
* @param args
*/
public static void main(String[] args) {
String wktGeom;
wktGeom = "LINESTRING(3 4,10 50,20 25)";
try {
Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String url = "jdbc:postgresql://localhost:5432/dcns_postgis";
Connection db = null;
try {
db = DriverManager.getConnection(url, "postgres", "");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Statement st = null;
try {
st = db.createStatement();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ResultSet rs = null;
try {
rs = st.executeQuery("SELECT type FROM geom_line WHERE gid = 4");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
while (rs.next()) {
System.out.print("Colonne 1 renvoyée ");
System.out.println(rs.getString(1));
System.out.println(wktGeom);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
st.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} |
Partager