OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
com.omnisci.jdbc.OmniSciGeomTest Class Reference
+ Collaboration diagram for com.omnisci.jdbc.OmniSciGeomTest:

Public Member Functions

void tst1_geometry () throws Exception
 
void tst2_geometry () throws Exception
 

Static Package Attributes

static Properties PROPERTIES = new Property_loader("connection.properties")
 
static final String url = PROPERTIES.getProperty("default_db_connection_url")
 
static final String user = PROPERTIES.getProperty("default_super_user")
 
static final String password = PROPERTIES.getProperty("default_user_password")
 
static String sql_drop_tbl_geom = "drop table if exists jdbc_geom"
 
static String sql_create_tbl_geom
 
static String sql_insert_geom
 
static String sql_insert_geom_batch = "insert into jdbc_geom values (?, ?, ?, ?)"
 
static String sql_select_geom = "select * from jdbc_geom"
 

Detailed Description

Definition at line 9 of file OmniSciGeomTest.java.

Member Function Documentation

void com.omnisci.jdbc.OmniSciGeomTest.tst1_geometry ( ) throws Exception
inline

Definition at line 30 of file OmniSciGeomTest.java.

References com.omnisci.jdbc.OmniSciGeomTest.password, com.omnisci.jdbc.OmniSciGeomTest.sql_create_tbl_geom, com.omnisci.jdbc.OmniSciGeomTest.sql_drop_tbl_geom, com.omnisci.jdbc.OmniSciGeomTest.sql_insert_geom, com.omnisci.jdbc.OmniSciGeomTest.sql_select_geom, com.omnisci.jdbc.OmniSciGeomTest.url, and com.omnisci.jdbc.OmniSciGeomTest.user.

30  {
31  Connection conn = DriverManager.getConnection(url, user, password);
32  assertNotEquals(null, conn);
33  Statement statement = conn.createStatement();
34  statement.executeUpdate(sql_drop_tbl_geom);
35  statement.executeUpdate(sql_create_tbl_geom);
36  statement.executeUpdate(sql_insert_geom);
37 
38  ResultSet rs = statement.executeQuery(sql_select_geom);
39  while (rs.next()) {
40  Object m_point = rs.getObject("m_point");
41  Object m_linestring = rs.getObject("m_linestring");
42  Object m_polygon = rs.getObject("m_polygon");
43  Object m_multi_polygon = rs.getString("m_multi_polygon");
44  assertEquals("POLYGON ((0 0,4 0,4 4,0 0))", m_polygon);
45  assertEquals("LINESTRING (0 1,2 2)", m_linestring);
46  assertEquals("POINT (0 0)", m_point);
47  assertEquals("MULTIPOLYGON (((0 0,4 0,4 4,0 4,0 0)))", m_multi_polygon);
48  }
49  rs.close();
50  statement.executeUpdate(sql_drop_tbl_geom);
51  }
void com.omnisci.jdbc.OmniSciGeomTest.tst2_geometry ( ) throws Exception
inline

Definition at line 55 of file OmniSciGeomTest.java.

References com.omnisci.jdbc.OmniSciGeomTest.password, com.omnisci.jdbc.OmniSciGeomTest.sql_create_tbl_geom, com.omnisci.jdbc.OmniSciGeomTest.sql_drop_tbl_geom, com.omnisci.jdbc.OmniSciGeomTest.sql_insert_geom_batch, com.omnisci.jdbc.OmniSciGeomTest.sql_select_geom, Experimental.String, com.omnisci.jdbc.OmniSciGeomTest.url, and com.omnisci.jdbc.OmniSciGeomTest.user.

55  {
56  Connection conn = DriverManager.getConnection(url, user, password);
57  assertNotEquals(null, conn);
58  Statement statement = conn.createStatement();
59  statement.executeUpdate(sql_drop_tbl_geom);
60  statement.executeUpdate(sql_create_tbl_geom);
61  PreparedStatement ps = conn.prepareStatement(sql_insert_geom_batch);
62  ps.setString(1, "POINT(0 0)");
63  ps.setString(2, "LINESTRING(0 1, 2 2)");
64  ps.setString(3, "POLYGON((0 0,4 0,4 4,0 0))");
65  ps.setString(4, "MULTIPOLYGON(((0 0,4 0,4 4,0 4,0 0)))");
66  ps.addBatch();
67  ps.executeBatch();
68 
69  ResultSet rs = statement.executeQuery(sql_select_geom);
70  while (rs.next()) {
71  // Test getString and getObject return on geo type
72  Object m_point = rs.getObject("m_point");
73  Object m_linestring = rs.getString("m_linestring");
74  Object m_polygon = rs.getObject("m_polygon");
75  String m_multi_polygon = rs.getString("m_multi_polygon");
76  assertEquals("POLYGON ((0 0,4 0,4 4,0 0))", m_polygon);
77  assertEquals("LINESTRING (0 1,2 2)", m_linestring);
78  assertEquals("POINT (0 0)", m_point);
79  assertEquals("MULTIPOLYGON (((0 0,4 0,4 4,0 4,0 0)))", m_multi_polygon);
80  }
81  rs.close();
82  statement.executeUpdate(sql_drop_tbl_geom);
83  }

Member Data Documentation

final String com.omnisci.jdbc.OmniSciGeomTest.password = PROPERTIES.getProperty("default_user_password")
staticpackage
Properties com.omnisci.jdbc.OmniSciGeomTest.PROPERTIES = new Property_loader("connection.properties")
staticpackage

Definition at line 10 of file OmniSciGeomTest.java.

String com.omnisci.jdbc.OmniSciGeomTest.sql_create_tbl_geom
staticpackage
Initial value:
=
"create table jdbc_geom (m_point POINT, m_linestring LINESTRING, m_polygon POLYGON, m_multi_polygon MULTIPOLYGON)"

Definition at line 16 of file OmniSciGeomTest.java.

Referenced by com.omnisci.jdbc.OmniSciGeomTest.tst1_geometry(), and com.omnisci.jdbc.OmniSciGeomTest.tst2_geometry().

String com.omnisci.jdbc.OmniSciGeomTest.sql_drop_tbl_geom = "drop table if exists jdbc_geom"
staticpackage
String com.omnisci.jdbc.OmniSciGeomTest.sql_insert_geom
staticpackage
Initial value:
=
"insert into jdbc_geom values ('POINT(0 0)', 'LINESTRING(0 1, 2 2)',"
+ " 'POLYGON((0 0,4 0,4 4,0 0))',"
+ " 'MULTIPOLYGON(((0 0,4 0,4 4,0 4,0 0)))')"

Definition at line 19 of file OmniSciGeomTest.java.

Referenced by com.omnisci.jdbc.OmniSciGeomTest.tst1_geometry().

String com.omnisci.jdbc.OmniSciGeomTest.sql_insert_geom_batch = "insert into jdbc_geom values (?, ?, ?, ?)"
staticpackage

Definition at line 24 of file OmniSciGeomTest.java.

Referenced by com.omnisci.jdbc.OmniSciGeomTest.tst2_geometry().

String com.omnisci.jdbc.OmniSciGeomTest.sql_select_geom = "select * from jdbc_geom"
staticpackage
final String com.omnisci.jdbc.OmniSciGeomTest.url = PROPERTIES.getProperty("default_db_connection_url")
staticpackage
final String com.omnisci.jdbc.OmniSciGeomTest.user = PROPERTIES.getProperty("default_super_user")
staticpackage

The documentation for this class was generated from the following file: