/** 同一个Statement先更新后查询 */
 @Test
 public void testExecuteSql() throws SQLException {
   TGroupConnection conn = null;
   Statement stat = null;
   try {
     conn = tgds.getConnection();
     stat = conn.createStatement();
     boolean res = stat.execute("update t set name = 'newName'");
     Assert.assertEquals(res, false);
     res = stat.execute("select * from xxx where id=0");
     Assert.assertEquals(res, true);
     MockDataSource.showTrace();
   } finally {
     if (conn != null) {
       try {
         conn.close();
       } catch (SQLException e) {
       }
       if (stat != null) {
         try {
           stat.close();
         } catch (SQLException e) {
         }
       }
     }
   }
 }
 @Test
 public void testAddBatchSql() throws SQLException {
   TGroupConnection conn = null;
   Statement stat = null;
   try {
     conn = tgds.getConnection();
     stat = conn.createStatement();
     stat.addBatch("update t set name = 'newName' ");
     stat.addBatch("update t set type = 2 ");
     int[] affectedRow = stat.executeBatch();
     System.out.println(Arrays.toString(affectedRow));
     MockDataSource.showTrace();
     Assert.assertTrue(MockDataSource.hasMethod("db", "db1", "executeBatch"));
   } finally {
     if (conn != null) {
       try {
         conn.close();
       } catch (SQLException e) {
       }
       if (stat != null) {
         try {
           stat.close();
         } catch (SQLException e) {
         }
       }
     }
   }
 }
  @Test
  public void java_sql_Statement_api_support() throws Exception {
    TGroupConnection conn = null;
    Statement stmt = null;
    try {
      conn = tgds.getConnection();
      stmt = conn.createStatement();

      String insertSQL = "insert into crud(f1,f2) values(10,'str')";
      String updateSQL = "update crud set f2='str2'";
      String selectSQL = "select * from crud";
      String showSQL = "show create table crud";

      assertFalse(stmt.execute(insertSQL));
      assertTrue(stmt.execute(selectSQL));
      assertTrue(stmt.execute(showSQL));
      assertFalse(stmt.execute(insertSQL, Statement.RETURN_GENERATED_KEYS));
      assertFalse(stmt.execute(insertSQL, new int[] {1}));
      assertFalse(stmt.execute(insertSQL, new String[] {"col"}));

      stmt.addBatch(insertSQL);
      stmt.addBatch(updateSQL);

      int[] updateCounts = stmt.executeBatch();
      assertEquals(updateCounts.length, 2);
      MockDataSource.addPreData("id:1,name:2");
      assertTrue(stmt.executeQuery(selectSQL).next());
      assertEquals(stmt.executeUpdate(insertSQL), 1);
      assertEquals(stmt.executeUpdate(insertSQL, Statement.RETURN_GENERATED_KEYS), 1);
      assertEquals(stmt.executeUpdate(insertSQL, new int[] {1}), 1);
      assertEquals(stmt.executeUpdate(insertSQL, new String[] {"col"}), 1);
    } finally {
      if (conn != null) {
        try {
          conn.close();
        } catch (SQLException e) {
        }

        if (stmt != null) {
          try {
            stmt.close();
          } catch (SQLException e) {
          }
        }
      }
    }
  }