Examples of ResultSet


Examples of java.sql.ResultSet

    query += key[i].toString();
  }
      }
    }
    boolean retval = false;
    ResultSet rs = select(query);
    if (rs.next()) {
      retval = true;
      if (rs.next()) {
  throw new Exception("More than one result entry "
      + "for result key: " + query);
      }
    }
    close(rs);

Examples of java.sql.ResultSet

  } else {
    query += key[i].toString();
  }
      }
    }
    ResultSet rs = select(query);
    ResultSetMetaData md = rs.getMetaData();
    int numAttributes = md.getColumnCount();
    if (!rs.next()) {
      throw new Exception("No result for query: " + query);
    }
    // Extract the columns for the result
    Object [] result = new Object [numAttributes];
    for(int i = 1; i <= numAttributes; i++) {
      switch (translateDBColumnType(md.getColumnTypeName(i))) {
  case STRING :
    result[i - 1] = rs.getString(i);
    if (rs.wasNull()) {
      result[i - 1] = null;
    }
    break;
  case FLOAT:
  case DOUBLE:
    result[i - 1] = new Double(rs.getDouble(i));
    if (rs.wasNull()) {
      result[i - 1] = null;
    }
    break;
  default:
    throw new Exception("Unhandled SQL result type (field " + (i + 1)
        + "): "
        + DatabaseUtils.typeName(md.getColumnType(i)));
      }
    }
    if (rs.next()) {
      throw new Exception("More than one result entry "
        + "for result key: " + query);
    }
    close(rs);
    return result;

Examples of java.sql.ResultSet

     
      //}

    // Get the number of rows
    String query = "SELECT COUNT(*) FROM " + EXP_INDEX_TABLE;
    ResultSet rs = select(query);
    if (m_Debug) {
      System.err.println("...getting number of rows");
    }
    if (rs.next()) {
      numRows = rs.getInt(1);
    }
    close(rs);

    // Add an entry in the index table
    String expType = rp.getClass().getName();

Examples of java.sql.ResultSet

    String query = "SELECT " + EXP_RESULT_COL
      + " FROM " + EXP_INDEX_TABLE
       + " WHERE " + EXP_TYPE_COL + "='" + expType
      + "' AND " + EXP_SETUP_COL + "='" + expParams + "'";
    String tableName = null;
    ResultSet rs = select(query);
    if (rs.next()) {
      tableName = rs.getString(1);
      if (rs.next()) {
  throw new Exception("More than one index entry "
      + "for experiment config: " + query);
      }
    }
    close(rs);

Examples of java.sql.ResultSet

      DataSource ds = (DataSource)new InitialContext().lookup(datasource);
      Connection conn = ds.getConnection();
      boolean load = false;

      Statement st = conn.createStatement();
      ResultSet rs = null;
      try
      {
         rs = st.executeQuery(existsSql.trim());
         rs.close();
      }
      catch (SQLException e)
      {
         load = true;
      }

Examples of java.sql.ResultSet

     * @param sql the SQL statement to execute
     * @param expected the expected result value
     * @throws AssertionError if a different result value was returned
     */
    protected void assertSingleValue(Statement stat, String sql, int expected) throws SQLException {
        ResultSet rs = stat.executeQuery(sql);
        assertTrue(rs.next());
        assertEquals(expected, rs.getInt(1));
        assertFalse(rs.next());
    }

Examples of java.sql.ResultSet

     * @param stat the statement
     * @param sql the SQL statement to execute
     * @throws AssertionError if a different result value was returned
     */
    protected void assertResult(String expected, Statement stat, String sql) throws SQLException {
        ResultSet rs = stat.executeQuery(sql);
        if (rs.next()) {
            String actual = rs.getString(1);
            assertEquals(expected, actual);
        } else {
            assertEquals(expected, null);
        }
    }

Examples of java.sql.ResultSet

     * @param stat1 the connection to the first database
     * @param stat2 the connection to the second database
     * @throws AssertionError if the databases don't match
     */
    protected void assertEqualDatabases(Statement stat1, Statement stat2) throws SQLException {
        ResultSet rs = stat1.executeQuery("select value from information_schema.settings where name='ANALYZE_AUTO'");
        int analyzeAuto = rs.next() ? rs.getInt(1) : 0;
        if (analyzeAuto > 0) {
            stat1.execute("analyze");
            stat2.execute("analyze");
        }
        ResultSet rs1 = stat1.executeQuery("SCRIPT simple NOPASSWORDS");
        ResultSet rs2 = stat2.executeQuery("SCRIPT simple NOPASSWORDS");
        ArrayList<String> list1 = new ArrayList<String>();
        ArrayList<String> list2 = new ArrayList<String>();
        while (rs1.next()) {
            String s1 = rs1.getString(1);
            if (!rs2.next()) {
                fail("expected: " + s1);
            }
            String s2 = rs2.getString(1);
            if (!s1.equals(s2)) {
                list1.add(s1);
                list2.add(s2);
            }
        }
        for (String s : list1) {
            if (!list2.remove(s)) {
                fail("only found in first: " + s);
            }
        }
        assertEquals(0, list2.size());
        assertFalse(rs2.next());
    }

Examples of java.sql.ResultSet

        throw e.getTargetException();
      }
    }
    if (decode && (EXECUTEQUERY.equals(method) || GETRESULTSET.equals(method))){
      try {
        ResultSet rs = (ResultSet) m.invoke(statement, args);
        return (new _ResultSet(rs, decode)).getResultSet();
      } catch (InvocationTargetException e) {
        throw e.getTargetException();
      }
    }

Examples of java.sql.ResultSet

    Hashtable htLevels = new Hashtable();
    Statement statement;
    String SQLQuery = "SELECT LJLEVEL, LCODE, nvl(LSYSLOGEQUIV,LLEVEL)  LSYSLOGEQUIV " +
                        "FROM TLOGLEVEL " +
                    "ORDER BY LLEVEL";
    ResultSet rs = null;
    Connection jdbc_conn = null;
         
    if (formatOK == false)
    {
      logger.log(Level.FATAL, "Connection parameters are not OK");   
    }
    else
   
      try{
        // connect to database
        Class.forName("oracle.jdbc.driver.OracleDriver");
        jdbc_conn = DriverManager.getConnection(JDBCurl, DbUser, DbPass);
         
        logger.debug( "JDBC Connection OK: " + jdbc_conn.toString());
         
        // get the PL/SQL and corresponding LOG4J log levels
        statement = jdbc_conn.createStatement();
        rs = statement.executeQuery(SQLQuery);
           
        if (rs != null)
        {
          while(rs.next())
          {
            Level l = new DynamicLevel (rs.getInt("LJLEVEL"),rs.getString("LCODE"),rs.getInt("LSYSLOGEQUIV"));
                Integer levelint = new Integer(rs.getInt("LSYSLOGEQUIV"));
             
                htLevels.put(levelint, l);
          }
        }
         
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.