Package java.sql

Examples of java.sql.PreparedStatement.executeQuery()


        prep.executeQuery();
        prep.close();

        prep = conn.prepareStatement("SELECT full_name FROM test WHERE (SUBSTRING(name, 1, 1) + SUBSTRING(surname, 2, 3)) = ?");
        prep.setString(1, "Joe");
        ResultSet res = prep.executeQuery();
        assertTrue("Result cannot be empty", res.next());
        assertEquals("John, Doe", res.getString(1));
        res.close();
        prep.close();
View Full Code Here


 
  @Test public void testPkPrepared() throws Exception {
    PreparedStatement stmt = conn.prepareStatement("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'");
    ResultSet rs = stmt.executeQuery();
    TestMMDatabaseMetaData.compareResultSet(rs);
 
 
  @Test public void testPreparedError() throws Exception {
    PreparedStatement stmt = conn.prepareStatement("select cast(? as integer)");
View Full Code Here

 
  @Test public void testPreparedError() throws Exception {
    PreparedStatement stmt = conn.prepareStatement("select cast(? as integer)");
    stmt.setString(1, "a");
    try {
      stmt.executeQuery();
    } catch (SQLException e) {
      assertTrue(e.getMessage().contains("Error converting"));
    }
  }
 
View Full Code Here

  }
 
  @Test public void testPreparedError1() throws Exception {
    PreparedStatement stmt = conn.prepareStatement("select");
    try {
      stmt.executeQuery();
    } catch (SQLException e) {
      assertTrue(e.getMessage().contains("Parsing error"));
    }
  }
 
View Full Code Here

            if (!translatedComm.isPrepared()) {
                results = getStatement().executeQuery(sql);
            } else {
              PreparedStatement pstatement = getPreparedStatement(sql);
                bindPreparedStatementValues(pstatement, translatedComm, 1);
                results = pstatement.executeQuery();
            }
            addStatementWarnings();
        } catch (SQLException e) {
            throw new JDBCExecutionException(e, translatedComm);
        }
View Full Code Here

                prep.setInt(2, random.nextInt(10));
                prep.execute();
            } else {
                PreparedStatement prep = conn.prepareStatement("select * from news where id = ?");
                prep.setInt(1, random.nextInt(getNewsCount()));
                ResultSet rs = prep.executeQuery();
                if (!rs.next()) {
                    System.out.println("No row found");
                    // throw new AssertionError("No row found");
                }
                if (rs.next()) {
View Full Code Here

                    prep = conn.prepareStatement("SELECT * FROM NEWS WHERE LINK = ?");
                } else {
                    prep = conn.prepareStatement("SELECT * FROM NEWS WHERE VALUE = ?");
                }
                prep.setString(1, PREFIX_URL + random.nextInt(len));
                ResultSet rs = prep.executeQuery();
                if (!rs.next()) {
                    throw new SQLException("expected one row, got none");
                }
                if (rs.next()) {
                    throw new SQLException("expected one row, got more");
View Full Code Here

        for (int i = 0; i < size; i++) {
            conn.prepareStatement("SELECT * FROM TEST");
        }
        prep = conn.prepareStatement("SELECT * FROM TEST WHERE 1=0");
        for (int i = 0; i < size; i++) {
            prep.executeQuery();
        }
        prep = conn.prepareStatement("SELECT * FROM TEST");
        for (int i = 0; i < size; i++) {
            prep.executeQuery();
        }
View Full Code Here

        for (int i = 0; i < size; i++) {
            prep.executeQuery();
        }
        prep = conn.prepareStatement("SELECT * FROM TEST");
        for (int i = 0; i < size; i++) {
            prep.executeQuery();
        }
        SysProperties.runFinalize = true;
        conn.close();
    }

View Full Code Here

        Object result = null;
        try {
            stmt = conn.prepareStatement(sql);
            fillStatement(stmt, params);
            verboseQuery(sql, params);
            rs = stmt.executeQuery();
            result = rsh.handle(rs);
        } catch (SQLException e) {
            rethrow(e, sql, params);
        } finally {
            try {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.