OmniSciDB  c07336695a
com.omnisci.jdbc.OmniSciStatementTest Class Reference
+ Collaboration diagram for com.omnisci.jdbc.OmniSciStatementTest:

Public Member Functions

void setUp () throws Exception
 
void tearDown () throws Exception
 
void insert_times () throws Exception
 
void create_times () throws Exception
 
void create_types () 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_tm = "drop table if exists test_jdbc_tm_tble"
 
static String sql_create_tbl_tm
 
static String sql_insert_tm_1
 
static String sql_insert_tm_2
 
static String sql_insert_tm_3
 
static String insert_prepare_tm
 
static String sql_insert_tm_4
 
static String sql_select_tm = "select * from test_jdbc_tm_tble"
 
static String sql_drop_tbl = "drop table if exists test_jdbc_types_tble"
 
static String sql_create_tbl
 
static String sql_insert
 
static String sql_select_all = "select * from test_jdbc_types_tble"
 

Private Attributes

Connection m_conn = null
 

Detailed Description

Definition at line 18 of file OmniSciStatementTest.java.

Member Function Documentation

◆ create_times()

void com.omnisci.jdbc.OmniSciStatementTest.create_times ( ) throws Exception
inline

Definition at line 111 of file OmniSciStatementTest.java.

111  {
112  Statement statement = m_conn.createStatement();
113  statement.executeUpdate(sql_drop_tbl_tm);
114  statement.executeUpdate(sql_create_tbl_tm);
115 
116  statement.executeUpdate(sql_insert_tm_1);
117  statement.executeUpdate(sql_insert_tm_2);
118  statement.executeUpdate(sql_insert_tm_3);
119  statement.executeUpdate(sql_insert_tm_4);
120  ResultSet rs = statement.executeQuery(sql_select_tm);
121 
122  for (int i = 0; rs.next(); ++i) {
123  TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
124  Timestamp timestamp = rs.getTimestamp("m_timestamp");
125 
126  Timestamp timestamp_3 = rs.getTimestamp("m_timestamp_3");
127  Timestamp timestamp_6 = rs.getTimestamp("m_timestamp_6");
128  Timestamp timestamp_9 = rs.getTimestamp("m_timestamp_9");
129  if (i == 0) {
130  assertEquals("1910-01-01 00:00:10.0", timestamp.toString());
131  assertEquals("1910-01-01 00:00:10.001", timestamp_3.toString());
132  assertEquals("1910-01-01 00:00:10.555556", timestamp_6.toString());
133  assertEquals("1910-01-01 00:00:10.999999999", timestamp_9.toString());
134  }
135  if (i == 1) {
136  assertEquals("1969-12-31 23:00:00.0", timestamp.toString());
137  assertEquals("1969-12-31 23:00:00.001", timestamp_3.toString());
138  assertEquals("1969-12-31 23:00:00.000001", timestamp_6.toString());
139  assertEquals("1969-12-31 23:00:00.000000001", timestamp_9.toString());
140  }
141  if (i == 2) {
142  assertEquals("1970-01-01 00:00:10.0", timestamp.toString());
143  assertEquals("1970-01-01 00:00:10.001", timestamp_3.toString());
144  assertEquals("1970-01-01 00:00:10.000001", timestamp_6.toString());
145  assertEquals("1970-01-01 00:00:10.000000001", timestamp_9.toString());
146  }
147  if (i == 3) {
148  assertEquals("2970-01-01 00:00:10.0", timestamp.toString());
149  assertEquals("2970-01-01 00:00:10.001", timestamp_3.toString());
150  assertEquals("2970-01-01 00:00:10.000001", timestamp_6.toString());
151  assertEquals("2262-04-11 23:47:16.850000001", timestamp_9.toString());
152  }
153  }
154 
155  statement.executeUpdate(sql_drop_tbl_tm);
156  }

◆ create_types()

void com.omnisci.jdbc.OmniSciStatementTest.create_types ( ) throws Exception
inline

Definition at line 185 of file OmniSciStatementTest.java.

References Double, Float, Integer, and Experimental.String.

185  {
186  Statement statement = m_conn.createStatement();
187  statement.executeUpdate(sql_drop_tbl);
188 
189  statement.executeUpdate(sql_create_tbl);
190  statement.executeUpdate(sql_insert);
191  statement.executeUpdate(sql_insert);
192  ResultSet rs = statement.executeQuery(sql_select_all);
193 
194  int i = 0;
195  for (; rs.next(); ++i) {
196  int r_int = rs.getInt("m_int");
197  assertEquals(Integer.MAX_VALUE, r_int);
198  float r_float = rs.getFloat("m_float");
199  float delta_f = ulp(Float.MAX_VALUE);
200  assertEquals(Float.MAX_VALUE, r_float, delta_f);
201 
202  double r_double = rs.getDouble("m_double");
203  double delta_d = ulp(Double.MAX_VALUE);
204  assertEquals(Double.MAX_VALUE, r_double, delta_d);
205 
206  long r_long = rs.getLong("m_bigint");
207  assertEquals(Long.MAX_VALUE, r_long);
208 
209  short r_short = rs.getShort("m_smallint");
210  assertEquals(Short.MAX_VALUE, r_short);
211 
212  byte r_byte = (byte) rs.getShort("m_tinyint");
213  assertEquals(Byte.MAX_VALUE, r_byte);
214 
215  String decimal_str = rs.getString("m_decimal");
216  assertEquals("12345.123", decimal_str);
217 
218  // byte r_boolean = rs.getByte("m_boolean"); Not supported!
219  byte r_boolean = (byte) rs.getShort("m_boolean");
220  assertEquals(0, r_boolean);
221 
222  String r_text_encoded = rs.getString("m_text_encoded");
223  assertEquals("String 1 - encoded", r_text_encoded);
224 
225  String r_text_encoded_none = rs.getString("m_text_encoded_none");
226  assertEquals("String 2 - not encoded", r_text_encoded_none);
227 
228  // Set the tz to GMT to help with compares
229  TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
230 
231  Timestamp r_timestamp = rs.getTimestamp("m_timestamp");
232  assertEquals("1970-01-01 00:00:00.0", r_timestamp.toString());
233 
234  Date r_date = rs.getDate("m_date");
235  assertEquals("1970-01-01", r_date.toString());
236 
237  Time r_time = rs.getTime("m_time");
238  assertEquals("00:00:00", r_time.toString());
239  }
240 
241  assertEquals(2, i);
242 
243  statement.executeUpdate(sql_drop_tbl);
244  }

◆ insert_times()

void com.omnisci.jdbc.OmniSciStatementTest.insert_times ( ) throws Exception
inline

Definition at line 65 of file OmniSciStatementTest.java.

65  {
66  Statement statement = m_conn.createStatement();
67  statement.executeUpdate(sql_drop_tbl_tm);
68  statement.executeUpdate(sql_create_tbl_tm);
69 
70  TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
71  DateFormat date_format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
72 
73  java.util.Date date_tm = date_format.parse("1918-11-11 11:11:00.000");
74  Timestamp tm = new Timestamp(date_tm.getTime());
75 
76  date_tm = date_format.parse("1918-11-11 11:11:00.001");
77  Timestamp tm_3 = new Timestamp(date_tm.getTime());
78 
79  date_tm = date_format.parse("1918-11-11 11:11:00.000");
80  Timestamp tm_6 = new Timestamp(date_tm.getTime());
81  tm_6.setNanos(999999000);
82 
83  date_tm = date_format.parse("1918-11-11 11:11:00.000");
84  Timestamp tm_9 = new Timestamp(date_tm.getTime());
85  tm_9.setNanos(123456789);
86 
87  PreparedStatement pr = m_conn.prepareStatement(insert_prepare_tm);
88  pr.setTimestamp(1, tm);
89  pr.setTimestamp(2, tm_3);
90  pr.setTimestamp(3, tm_6);
91  pr.setTimestamp(4, tm_9);
92 
93  pr.executeUpdate();
94 
95  ResultSet rs = statement.executeQuery(sql_select_tm);
96  while (rs.next()) {
97  Timestamp r_tm = rs.getTimestamp("m_timestamp");
98  assertTrue(r_tm.equals(tm));
99  Timestamp r_tm3 = rs.getTimestamp("m_timestamp_3");
100  assertTrue(r_tm3.equals(tm_3));
101  Timestamp r_tm6 = rs.getTimestamp("m_timestamp_6");
102  assertTrue(r_tm6.equals(tm_6));
103  Timestamp r_tm9 = rs.getTimestamp("m_timestamp_9");
104  assertTrue(r_tm9.equals(tm_9));
105  }
106 
107  statement.executeUpdate(sql_drop_tbl_tm);
108  }

◆ setUp()

void com.omnisci.jdbc.OmniSciStatementTest.setUp ( ) throws Exception
inline

Definition at line 27 of file OmniSciStatementTest.java.

27  {
28  Properties pt = new Properties();
29  pt.setProperty("user", user);
30  pt.setProperty("password", password);
31  m_conn = DriverManager.getConnection(url, pt);
32  }

◆ tearDown()

void com.omnisci.jdbc.OmniSciStatementTest.tearDown ( ) throws Exception
inline

Definition at line 35 of file OmniSciStatementTest.java.

35  {
36  m_conn.close();
37  }

Member Data Documentation

◆ insert_prepare_tm

String com.omnisci.jdbc.OmniSciStatementTest.insert_prepare_tm
staticpackage
Initial value:
=
"insert into test_jdbc_tm_tble (m_timestamp, m_timestamp_3, m_timestamp_6, m_timestamp_9) values (?, ?, ?, ?)"

Definition at line 56 of file OmniSciStatementTest.java.

◆ m_conn

Connection com.omnisci.jdbc.OmniSciStatementTest.m_conn = null
private

Definition at line 24 of file OmniSciStatementTest.java.

◆ password

final String com.omnisci.jdbc.OmniSciStatementTest.password = PROPERTIES.getProperty("default_user_password")
staticpackage

Definition at line 22 of file OmniSciStatementTest.java.

◆ PROPERTIES

Properties com.omnisci.jdbc.OmniSciStatementTest.PROPERTIES = new Property_loader("connection.properties")
staticpackage

Definition at line 19 of file OmniSciStatementTest.java.

◆ sql_create_tbl

String com.omnisci.jdbc.OmniSciStatementTest.sql_create_tbl
staticpackage
Initial value:
= "CREATE table test_jdbc_types_tble("
+ "m_decimal DECIMAL(8,3),"
+ "m_int int,"
+ "m_float float,"
+ "m_double double,"
+ "m_bigint BIGINT,"
+ "m_smallint SMALLINT,"
+ "m_tinyint TINYINT,"
+ "m_boolean BOOLEAN,"
+ "m_text_encoded TEXT ENCODING DICT,"
+ "m_text_encoded_none TEXT ENCODING NONE,"
+ "m_time TIME,"
+ "m_date DATE,"
+ "m_timestamp TIMESTAMP)"

Definition at line 160 of file OmniSciStatementTest.java.

◆ sql_create_tbl_tm

String com.omnisci.jdbc.OmniSciStatementTest.sql_create_tbl_tm
staticpackage
Initial value:
= "CREATE table test_jdbc_tm_tble("
+ "m_timestamp TIMESTAMP,"
+ "m_timestamp_3 TIMESTAMP(3),"
+ "m_timestamp_6 TIMESTAMP(6),"
+ "m_timestamp_9 TIMESTAMP(9))"

Definition at line 41 of file OmniSciStatementTest.java.

◆ sql_drop_tbl

String com.omnisci.jdbc.OmniSciStatementTest.sql_drop_tbl = "drop table if exists test_jdbc_types_tble"
staticpackage

Definition at line 158 of file OmniSciStatementTest.java.

◆ sql_drop_tbl_tm

String com.omnisci.jdbc.OmniSciStatementTest.sql_drop_tbl_tm = "drop table if exists test_jdbc_tm_tble"
staticpackage

Definition at line 39 of file OmniSciStatementTest.java.

◆ sql_insert

String com.omnisci.jdbc.OmniSciStatementTest.sql_insert
staticpackage
Initial value:
= "insert into test_jdbc_types_tble values ("
+ "12345.123" + +Integer.MAX_VALUE + "," + Integer.MAX_VALUE + ","
+ Float.MAX_VALUE + "," + Double.MAX_VALUE + "," + Long.MAX_VALUE + ","
+ Short.MAX_VALUE + "," + Byte.MAX_VALUE + ","
+ "\'0\',"
+ "'String 1 - encoded', 'String 2 - not encoded', '00:00:00', '1970-01-01', '1970-01-01 00:00:00')"

Definition at line 175 of file OmniSciStatementTest.java.

◆ sql_insert_tm_1

String com.omnisci.jdbc.OmniSciStatementTest.sql_insert_tm_1
staticpackage
Initial value:
=
"insert into test_jdbc_tm_tble values ('1910-01-01 00:00:10', '1910-01-01 00:00:10.001', '1910-01-01 00:00:10.555556', '1910-01-01 00:00:10.999999999')"

Definition at line 47 of file OmniSciStatementTest.java.

◆ sql_insert_tm_2

String com.omnisci.jdbc.OmniSciStatementTest.sql_insert_tm_2
staticpackage
Initial value:
=
"insert into test_jdbc_tm_tble values ('1969-12-31 23:00:00', '1969-12-31 23:00:00.001', '1969-12-31 23:00:00.000001', '1969-12-31 23:00:00.000000001')"

Definition at line 50 of file OmniSciStatementTest.java.

◆ sql_insert_tm_3

String com.omnisci.jdbc.OmniSciStatementTest.sql_insert_tm_3
staticpackage
Initial value:
=
"insert into test_jdbc_tm_tble values ('1970-01-01 00:00:10', '1970-01-01 00:00:10.001', '1970-01-01 00:00:10.000001', '1970-01-01 00:00:10.000000001')"

Definition at line 53 of file OmniSciStatementTest.java.

◆ sql_insert_tm_4

String com.omnisci.jdbc.OmniSciStatementTest.sql_insert_tm_4
staticpackage
Initial value:
=
"insert into test_jdbc_tm_tble values ('2970-01-01 00:00:10', '2970-01-01 00:00:10.001', '2970-01-01 00:00:10.000001', '2262-04-11 23:47:16.850000001')"

Definition at line 60 of file OmniSciStatementTest.java.

◆ sql_select_all

String com.omnisci.jdbc.OmniSciStatementTest.sql_select_all = "select * from test_jdbc_types_tble"
staticpackage

Definition at line 182 of file OmniSciStatementTest.java.

◆ sql_select_tm

String com.omnisci.jdbc.OmniSciStatementTest.sql_select_tm = "select * from test_jdbc_tm_tble"
staticpackage

Definition at line 62 of file OmniSciStatementTest.java.

◆ url

final String com.omnisci.jdbc.OmniSciStatementTest.url = PROPERTIES.getProperty("default_db_connection_url")
staticpackage

Definition at line 20 of file OmniSciStatementTest.java.

◆ user

final String com.omnisci.jdbc.OmniSciStatementTest.user = PROPERTIES.getProperty("default_super_user")
staticpackage

Definition at line 21 of file OmniSciStatementTest.java.


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