7
7
import java .sql .Connection ;
8
8
import java .sql .ParameterMetaData ;
9
9
import java .sql .PreparedStatement ;
10
+ import java .sql .ResultSetMetaData ;
10
11
import java .sql .SQLException ;
11
12
import java .sql .Statement ;
12
13
import java .util .Arrays ;
@@ -101,7 +102,7 @@ public void exceptionTest() throws SQLException {
101
102
}
102
103
103
104
@ Test
104
- public void tempTableTest () throws SQLException {
105
+ public void getParameterMetaDataTest () throws SQLException {
105
106
String tempTableName = "[#jdbc_temp" + UUID .randomUUID () + "]" ;
106
107
try (Connection c = PrepUtil .getConnection (AbstractTest .connectionString + ";useFmtOnly=true;" );
107
108
Statement s = c .createStatement ()) {
@@ -118,6 +119,29 @@ public void tempTableTest() throws SQLException {
118
119
}
119
120
}
120
121
122
+ /**
123
+ * Tests sql containing TOP
124
+ *
125
+ * @throws SQLException
126
+ */
127
+ @ Test
128
+ public void getMetaDataTest () throws SQLException {
129
+ String tempTableName = "[#jdbc_temp" + UUID .randomUUID () + "]" ;
130
+ try (Connection c = PrepUtil .getConnection (AbstractTest .connectionString + ";useFmtOnly=true;" );
131
+ Statement s = c .createStatement (); PreparedStatement p = c
132
+ .prepareStatement ("SELECT TOP(?) [c1] FROM " + tempTableName + " WHERE c1 = ?" )) {
133
+ TestUtils .dropTableIfExists (tempTableName , s );
134
+ s .execute ("CREATE TABLE " + tempTableName + " (c1 int)" );
135
+
136
+ ResultSetMetaData rmd = p .getMetaData ();
137
+ assertTrue (rmd .getColumnCount () == 1 );
138
+ } finally {
139
+ try (Statement s = connection .createStatement ()) {
140
+ TestUtils .dropTableIfExists (tempTableName , s );
141
+ }
142
+ }
143
+ }
144
+
121
145
@ Test
122
146
public void viewTest () throws SQLException {
123
147
String tempViewName = "[jdbc_view" + UUID .randomUUID () + "]" ;
0 commit comments