Package java.sql

Examples of java.sql.Statement


 
  /**
   * Under the covers this still executes a prepared statement due to the driver handling
   */
  @Test public void testSelect() throws Exception {
    Statement s = conn.createStatement();
    assertTrue(s.execute("select * from tables order by name"));
    TestMMDatabaseMetaData.compareResultSet(s.getResultSet());
  }
View Full Code Here


    assertTrue(s.execute("select * from tables order by name"));
    TestMMDatabaseMetaData.compareResultSet(s.getResultSet());
  }
 
  @Test public void testBlob() throws Exception {
    Statement s = conn.createStatement();
    assertTrue(s.execute("select to_bytes('abc', 'UTF-16')"));
    ResultSet rs = s.getResultSet();
    assertTrue(rs.next());
    byte[] bytes = rs.getBytes(1);
    assertEquals("abc", new String(bytes, Charset.forName("UTF-16")));
  }
View Full Code Here

    byte[] bytes = rs.getBytes(1);
    assertEquals("abc", new String(bytes, Charset.forName("UTF-16")));
  }
 
  @Test public void testClob() throws Exception {
    Statement s = conn.createStatement();
    assertTrue(s.execute("select cast('abc' as clob)"));
    ResultSet rs = s.getResultSet();
    assertTrue(rs.next());
    //getting as a clob is unsupported, since it uses the lo logic
    String clob = rs.getString(1);
    assertEquals("abc", clob);
  }
View Full Code Here

  }

  @Test public void testTransactionCycle() throws Exception {
    //TODO: drill in to ensure that the underlying statement has been set to autocommit false
    conn.setAutoCommit(false);
    Statement s = conn.createStatement();
    assertTrue(s.execute("select * from tables order by name"));
    conn.setAutoCommit(true);
  }
View Full Code Here

    assertTrue(s.execute("select * from tables order by name"));
    conn.setAutoCommit(true);
  }
 
  @Test public void testPk() throws Exception {
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select ta.attname, ia.attnum, ic.relname, n.nspname, tc.relname " +//$NON-NLS-1$
      "from pg_catalog.pg_attribute ta, pg_catalog.pg_attribute ia, pg_catalog.pg_class tc, pg_catalog.pg_index i, " +//$NON-NLS-1$
      "pg_catalog.pg_namespace n, pg_catalog.pg_class ic where tc.relname = E'pg_attribute' AND n.nspname = E'pg_catalog'");
    TestMMDatabaseMetaData.compareResultSet(rs);
  }
View Full Code Here

      assertTrue(e.getMessage().contains("Parsing error"));
    }
  }
 
  @Test public void testEscapedLiteral() throws Exception {
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select E'\\n\\thello pg'");
    assertTrue(rs.next());
    assertEquals("\n\thello pg", rs.getString(1));
  }
View Full Code Here

    assertTrue(rs.next());
    assertEquals("\n\thello pg", rs.getString(1));
  }
 
  @Test public void testPgProc() throws Exception {
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select * from pg_proc");
    rs.next();
    assertEquals("oid", rs.getArray("proargtypes").getBaseTypeName());
  }
View Full Code Here

    rs.next();
    assertEquals("oid", rs.getArray("proargtypes").getBaseTypeName());
  }
 
  @Test public void testPgProcedure() throws Exception {
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select has_function_privilege(100, 'foo')");
    rs.next();
  }
View Full Code Here

    @AfterClass public static void tearDown() throws SQLException {
      connection.close();
    }

    @Test public void testViewMetadataRepositoryMerge() throws Exception {
      Statement s = connection.createStatement();
      ResultSet rs = s.executeQuery("select * from vw");
      rs.next();
      assertEquals(2011, rs.getInt(1));
    }
View Full Code Here

      rs.next();
      assertEquals(2011, rs.getInt(1));
    }
   
    @Test(expected=SQLException.class) public void testViewUpdateMetadataRepositoryMerge() throws Exception {
      Statement s = connection.createStatement();
      s.execute("delete from vw");
    }
View Full Code Here

TOP

Related Classes of java.sql.Statement

Copyright © 2015 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.