01: package net.sourceforge.jtds.test;
02:
03: import java.sql.*;
04:
05: /**
06: * @created March 17, 2001
07: * @version 1.0
08: */
09: public class UpdateTest extends TestBase {
10:
11: public UpdateTest(String name) {
12: super (name);
13: }
14:
15: public void testTemp() throws Exception {
16: Statement stmt = con.createStatement(
17: ResultSet.TYPE_SCROLL_INSENSITIVE,
18: ResultSet.CONCUR_READ_ONLY);
19:
20: stmt
21: .execute("CREATE TABLE #temp (pk INT PRIMARY KEY, f_string VARCHAR(30), f_float FLOAT)");
22:
23: // populate in the traditional way
24: final int count = 100;
25: for (int i = 0; i < count; i++) {
26: stmt.execute("INSERT INTO #temp " + "VALUES( " + i + ","
27: + "'The String " + i + "'" + ", " + i + ")");
28: }
29:
30: dump(stmt.executeQuery("SELECT Count(*) FROM #temp"));
31:
32: //Navigate around
33: ResultSet rs = stmt.executeQuery("SELECT * FROM #temp");
34:
35: assertTrue(rs.first());
36: assertEquals(1, rs.getRow());
37: assertTrue(rs.last());
38: assertEquals(count, rs.getRow());
39: assertTrue(rs.first());
40: assertEquals(1, rs.getRow());
41:
42: rs.close();
43: stmt.close();
44: }
45:
46: public static void main(String[] args) {
47: junit.textui.TestRunner.run(UpdateTest.class);
48: }
49: }
|