I'm trying to use JDBC to display rows in a table created in an Oracle 11g Database, the problem is I don't manage to get the value of the attribute "SHAPE" of type "SDO_GEOMETRY" using the following code, which by the way works fine when it comes to the other attributes of the table :
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Driver O.K.");
String url = "jdbc:oracle:thin:@localhost:1521:xe";
String user = "system";
String passwd = "isima";
Connection conn = DriverManager.getConnection(url, user, passwd);
System.out.println("Connexion effective");
Statement myStmt = null;
ResultSet myRs = null;
myStmt = conn.createStatement();
myRs = myStmt.executeQuery("SELECT * FROM testGeo");
while (myRs.next()) {
System.out.println(myRs.getString("shape"));
}
} catch (Exception e) {
e.printStackTrace();
}
Here are the DDL statements used to create the testGeo table and some test data.
CREATE TABLE testGeo (
GeoID NUMBER PRIMARY KEY,
name VARCHAR2(32),
shape SDO_GEOMETRY);
INSERT INTO testGeo VALUES(
1,
'cola_a',
SDO_GEOMETRY(
2003,
NULL,
NULL,
SDO_ELEM_INFO_ARRAY(1,1003,3),
SDO_ORDINATE_ARRAY(1,1, 5,7)
)
);
INSERT INTO testGeo VALUES(
2,
'cola_b',
SDO_GEOMETRY(
2003,
NULL,
NULL,
SDO_ELEM_INFO_ARRAY(1,1003,3),
SDO_ORDINATE_ARRAY(2,1, 6,7)
)
);
INSERT INTO testGeo VALUES(
3,
'cola_c',
SDO_GEOMETRY(
2003,
NULL,
NULL,
SDO_ELEM_INFO_ARRAY(1,1003,3),
SDO_ORDINATE_ARRAY(1,1, 9,9)
)
);