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

Public Member Functions

void setUp () throws Exception
 
void tearDown () throws Exception
 
void prepare_test () throws Exception
 
void get_metadata () throws Exception
 

Static Package Attributes

static Properties PROPERTIES = new Property_loader("prepare_test.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")
 

Private Attributes

Connection m_conn = null
 

Detailed Description

Definition at line 13 of file OmniSciPrepareTest.java.

Member Function Documentation

void com.omnisci.jdbc.OmniSciPrepareTest.get_metadata ( ) throws Exception
inline

Definition at line 91 of file OmniSciPrepareTest.java.

References Experimental.String.

91  {
92  Statement statement = m_conn.createStatement();
93  statement.executeUpdate(PROPERTIES.getProperty("drop_base_t3"));
94  statement.executeUpdate(PROPERTIES.getProperty("create_base_t3"));
95  statement.executeQuery("insert into test_prepare_table3 values(1, 1.1, 'one')");
96  ResultSetMetaData md = null;
97 
98  PreparedStatement pr_select_no_params =
99  m_conn.prepareStatement("select aa, bb, cc from test_prepare_table3");
100  md = pr_select_no_params.getMetaData();
101  assertNotNull(md);
102  assertEquals(md.getColumnCount(), 3);
103  assertEquals(md.getColumnName(1), "aa");
104  assertEquals(md.getColumnType(1), Types.INTEGER);
105  assertEquals(md.getColumnType(2), Types.DOUBLE);
106 
107  PreparedStatement pr_select_with_params = m_conn.prepareStatement(
108  "select bb, aa from test_prepare_table3 where cc <> ? and aa > ?");
109  md = pr_select_with_params.getMetaData();
110  assertNotNull(md);
111  assertEquals(md.getColumnCount(), 2);
112  assertEquals(md.getColumnName(1), "bb");
113  assertEquals(md.getColumnType(1), Types.DOUBLE);
114  assertEquals(md.getColumnType(2), Types.INTEGER);
115 
116  String commented_sql_statement = " \n \n"
117  + "-- comment\n"
118  + "\n\n"
119  + "/*some\n"
120  + "multiline\n"
121  + "comment\n"
122  + "-- comment inside comment\n"
123  + "*/ \n"
124  + "-- another /*tricky edge case/*\n"
125  + " select bb, aa from test_prepare_table3 where cc <> ? and aa > ?";
126  PreparedStatement pr_select_with_params_and_comments =
127  m_conn.prepareStatement(commented_sql_statement);
128  md = pr_select_with_params_and_comments.getMetaData();
129  assertNotNull(md);
130  assertEquals(md.getColumnCount(), 2);
131 
132  PreparedStatement pr_insert = m_conn.prepareStatement(
133  "insert into test_prepare_table3(aa, bb, cc) values (?, ?, ?)");
134  md = pr_insert.getMetaData();
135  assertNull(md);
136 
137  PreparedStatement pr_insert_from_select = m_conn.prepareStatement(
138  "insert into test_prepare_table3(aa, bb, cc) select aa, bb, cc from test_prepare_table3 where cc <> ?");
139  md = pr_insert_from_select.getMetaData();
140  assertNull(md);
141 
142  statement.executeUpdate(PROPERTIES.getProperty("drop_base_t3"));
143  }
void com.omnisci.jdbc.OmniSciPrepareTest.prepare_test ( ) throws Exception
inline

Definition at line 35 of file OmniSciPrepareTest.java.

References Experimental.String.

35  {
36  Statement statement = m_conn.createStatement();
37  {
38  statement.executeUpdate(PROPERTIES.getProperty("drop_base_t1"));
39  statement.executeUpdate(PROPERTIES.getProperty("create_base_t1"));
40  String prepare_insert_statement =
41  "insert into test_prepare_table1 (cc, bb, aa) values (?,?,?)";
42  PreparedStatement pr1 = m_conn.prepareStatement(prepare_insert_statement);
43  int aa_i = 100;
44  int bb_i = 1000;
45  int cc_i = 10000;
46  pr1.setInt(1, cc_i);
47  pr1.setInt(2, bb_i);
48  pr1.setInt(3, aa_i);
49  pr1.executeUpdate();
50  ResultSet rs = statement.executeQuery("select cc, bb, aa from test_prepare_table1");
51 
52  while (rs.next()) {
53  int returned_cc = rs.getInt("cc");
54  assertEquals(cc_i, returned_cc);
55  int returned_bb = rs.getInt("bb");
56  assertEquals(bb_i, returned_bb);
57  int returned_aa = rs.getInt("aa");
58  assertEquals(aa_i, returned_aa);
59  }
60  statement.executeUpdate(PROPERTIES.getProperty("drop_base_t1"));
61  }
62  {
63  statement.executeUpdate(PROPERTIES.getProperty("drop_base_t2"));
64  statement.executeUpdate(PROPERTIES.getProperty("create_base_t2"));
65  String prepare_insert_statement2 =
66  "insert into test_prepare_table2 (cc, bb, aa) values (?,?,?)";
67  PreparedStatement pr2 = m_conn.prepareStatement(prepare_insert_statement2);
68  String aa_s = "100";
69  String bb_s = "1000";
70  String cc_s = "10000";
71  pr2.setString(1, cc_s);
72  pr2.setString(2, bb_s);
73  pr2.setString(3, aa_s);
74  pr2.executeUpdate();
75  ResultSet rs2 =
76  statement.executeQuery("select cc, bb, aa from test_prepare_table2");
77 
78  while (rs2.next()) {
79  String returned_cc = rs2.getString("cc");
80  assertEquals(cc_s, returned_cc);
81  String returned_bb = rs2.getString("bb");
82  assertEquals(bb_s, returned_bb);
83  String returned_aa = rs2.getString("aa");
84  assertEquals(aa_s, returned_aa);
85  }
86  statement.executeUpdate(PROPERTIES.getProperty("drop_base_t2"));
87  }
88  }
void com.omnisci.jdbc.OmniSciPrepareTest.setUp ( ) throws Exception
inline

Definition at line 22 of file OmniSciPrepareTest.java.

References com.omnisci.jdbc.OmniSciPrepareTest.m_conn, com.omnisci.jdbc.OmniSciPrepareTest.password, com.omnisci.jdbc.OmniSciPrepareTest.url, and com.omnisci.jdbc.OmniSciPrepareTest.user.

22  {
23  Properties pt = new Properties();
24  pt.setProperty("user", user);
25  pt.setProperty("password", password);
26  m_conn = DriverManager.getConnection(url, pt);
27  }
void com.omnisci.jdbc.OmniSciPrepareTest.tearDown ( ) throws Exception
inline

Definition at line 30 of file OmniSciPrepareTest.java.

30  {
31  m_conn.close();
32  }

Member Data Documentation

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

Definition at line 19 of file OmniSciPrepareTest.java.

Referenced by com.omnisci.jdbc.OmniSciPrepareTest.setUp().

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

Definition at line 17 of file OmniSciPrepareTest.java.

Referenced by com.omnisci.jdbc.OmniSciPrepareTest.setUp().

Properties com.omnisci.jdbc.OmniSciPrepareTest.PROPERTIES = new Property_loader("prepare_test.properties")
staticpackage

Definition at line 14 of file OmniSciPrepareTest.java.

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

Definition at line 15 of file OmniSciPrepareTest.java.

Referenced by com.omnisci.jdbc.OmniSciPrepareTest.setUp().

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

Definition at line 16 of file OmniSciPrepareTest.java.

Referenced by com.omnisci.jdbc.OmniSciPrepareTest.setUp().


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