|
4 | 4 | import java.sql.Connection;
|
5 | 5 | import java.sql.ResultSet;
|
6 | 6 | import java.sql.Statement;
|
| 7 | +import java.sql.SQLException; |
7 | 8 |
|
8 | 9 | import junit.framework.TestCase;
|
9 | 10 |
|
@@ -32,13 +33,21 @@ protected void setUp() throws Exception
|
32 | 33 | stmt.executeUpdate("INSERT INTO testrs VALUES (4)");
|
33 | 34 | stmt.executeUpdate("INSERT INTO testrs VALUES (6)");
|
34 | 35 | stmt.executeUpdate("INSERT INTO testrs VALUES (9)");
|
| 36 | + |
| 37 | + TestUtil.createTable(con, "teststring", "a text"); |
| 38 | + stmt.executeUpdate("INSERT INTO teststring VALUES ('12345')"); |
| 39 | + |
| 40 | + TestUtil.createTable(con, "testint", "a int"); |
| 41 | + stmt.executeUpdate("INSERT INTO testint VALUES (12345)"); |
35 | 42 |
|
36 | 43 | stmt.close();
|
37 | 44 | }
|
38 | 45 |
|
39 | 46 | protected void tearDown() throws Exception
|
40 | 47 | {
|
41 | 48 | TestUtil.dropTable(con, "testrs");
|
| 49 | + TestUtil.dropTable(con, "teststring"); |
| 50 | + TestUtil.dropTable(con, "testint"); |
42 | 51 | TestUtil.closeDB(con);
|
43 | 52 | }
|
44 | 53 |
|
@@ -85,4 +94,25 @@ public void testEmptyResult()
|
85 | 94 | }
|
86 | 95 |
|
87 | 96 | }
|
| 97 | + |
| 98 | + public void testMaxFieldSize() throws Exception |
| 99 | + { |
| 100 | + Statement stmt = con.createStatement(); |
| 101 | + stmt.setMaxFieldSize(2); |
| 102 | + |
| 103 | + ResultSet rs = stmt.executeQuery("select * from testint"); |
| 104 | + |
| 105 | + //max should not apply to the following since per the spec |
| 106 | + //it should apply only to binary and char/varchar columns |
| 107 | + rs.next(); |
| 108 | + assertEquals(rs.getString(1),"12345"); |
| 109 | + assertEquals(new String(rs.getBytes(1)), "12345"); |
| 110 | + |
| 111 | + //max should apply to the following since the column is |
| 112 | + //a varchar column |
| 113 | + rs = stmt.executeQuery("select * from teststring"); |
| 114 | + rs.next(); |
| 115 | + assertEquals(rs.getString(1), "12"); |
| 116 | + assertEquals(new String(rs.getBytes(1)), "12"); |
| 117 | + } |
88 | 118 | }
|
0 commit comments