Package com.caucho.management.server

Examples of com.caucho.management.server.JdbcQueryResult


   
    try {
      connection = _pool.getConnection();
      Statement statement = connection.createStatement();

      JdbcQueryResult result = new JdbcQueryResult();

      if (statement.execute(sql)) {
        ArrayList<String[]> rows = new ArrayList<String[]>();

        ResultSet resultSet = statement.getResultSet();
        ResultSetMetaData metadata = resultSet.getMetaData();
        int columnCount = metadata.getColumnCount();

        // add column names
        String []names = new String[columnCount];

        for (int i = 0; i < columnCount; i++)
          names[i] = metadata.getColumnName(i + 1);

        result.setRowNames(names);

        // add results
        while (resultSet.next()) {
          String []row = new String[columnCount];

          for (int i = 0; i < columnCount; i++) {
            try {
              row[i] = resultSet.getString(i + 1);
            }
            catch (SQLException e) {
              // MySQL zero date conversion issue
              if (e.getMessage().startsWith("Cannot convert value '0000-00-00"))
                row[i] = "0000-00-00 00:00:00";
              else
                throw e;
            }
          }

          rows.add(row);
        }

        String [][]rowsArray = new String[rows.size()][];
        rows.toArray(rowsArray);

        result.setResultData(rowsArray);

        return result;
      }

      return null;
View Full Code Here


   
    try {
      connection = _pool.getConnection();
      Statement statement = connection.createStatement();

      JdbcQueryResult result = new JdbcQueryResult();

      if (statement.execute(sql)) {
        ArrayList<String[]> rows = new ArrayList<String[]>();

        ResultSet resultSet = statement.getResultSet();
        ResultSetMetaData metadata = resultSet.getMetaData();
        int columnCount = metadata.getColumnCount();

        // add column names
        String []names = new String[columnCount];

        for (int i = 0; i < columnCount; i++)
          names[i] = metadata.getColumnName(i + 1);

        result.setRowNames(names);

        // add results
        while (resultSet.next()) {
          String []row = new String[columnCount];

          for (int i = 0; i < columnCount; i++) {
            try {
              row[i] = resultSet.getString(i + 1);
            }
            catch (SQLException e) {
              // MySQL zero date conversion issue
              if (e.getMessage().startsWith("Cannot convert value '0000-00-00"))
                row[i] = "0000-00-00 00:00:00";
              else
                throw e;
            }
          }

          rows.add(row);
        }

        String [][]rowsArray = new String[rows.size()][];
        rows.toArray(rowsArray);

        result.setResultData(rowsArray);

        return result;
      }

      return null;
View Full Code Here

TOP

Related Classes of com.caucho.management.server.JdbcQueryResult

Copyright © 2018 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.