Package java.sql

Examples of java.sql.SQLWarning


    boolean   passed = true;
    PreparedStatement  ps_f_r = null; // forward only, read only
    ResultSet  rs;
    ResultSetMetaData rsmd_ps;
    ResultSetMetaData rsmd_rs;
    SQLWarning  warning;


    ps_f_r = conn.prepareStatement(
                   "select c50, i, 43 from t",
                   ResultSet.TYPE_FORWARD_ONLY,
View Full Code Here


  }

  static void testUpdateDeleteWarning() throws SQLException {
    Statement stmt = conn.createStatement();
    stmt.executeUpdate("update t2 set c1 = 2 where c1 = 1");
    SQLWarning sw = stmt.getWarnings();
    if (sw != null)
      System.out.println("TEST FAILED!  The update should not return a warning.");
    stmt.executeUpdate("update t2 set c1 = 2 where c1 = 1");
    sw = stmt.getWarnings();
    String state, msg;
    if (sw == null)
      System.out.println("TEST FAILED!  The update should return a warning.");
    else
    {
      state = sw.getSQLState();
      if (! state.equals("02000"))
        System.out.println("TEST FAILED!  Wrong sql state.");
      msg = sw.getMessage();
      if (! msg.startsWith("No row was found for FETCH, UPDATE or DELETE"))
        System.out.println("TEST FAILED!  Wrong message: " + msg);
    }

    stmt.executeUpdate("delete from t2 where c1 = 2");
    sw = stmt.getWarnings();
    if (sw != null)
      System.out.println("TEST FAILED!  The delete should not return a warning.");
    stmt.executeUpdate("delete from t2 where c1 = 2");
    sw = stmt.getWarnings();
    if (sw == null)
      System.out.println("TEST FAILED!  The delete should return a warning.");
    else
    {
      state = sw.getSQLState();
      if (! state.equals("02000"))
        System.out.println("TEST FAILED!  Wrong sql state.");
      msg = sw.getMessage();
      if (! msg.startsWith("No row was found for FETCH, UPDATE or DELETE"))
        System.out.println("TEST FAILED!  Wrong message: " + msg);
    }

    stmt.executeUpdate("delete from t3");
    sw = stmt.getWarnings();
    if (sw == null)
      System.out.println("TEST FAILED!  The delete cascade should return a warning.");
    else
    {
      state = sw.getSQLState();
      if (! state.equals("02000"))
        System.out.println("TEST FAILED!  Wrong sql state.");
      msg = sw.getMessage();
      if (! msg.startsWith("No row was found for FETCH, UPDATE or DELETE"))
        System.out.println("TEST FAILED!  Wrong message: " + msg);
    }
  }
View Full Code Here

    }
  }

  public final SQLWarning getWarnings() {
    SQLWarning w = warnings;
    warnings = null;
    return w;
  }
View Full Code Here

                ps = theConnection.prepareStatement(sVal);
                JDBCDisplayUtil.checkNotNull(ps,"prepared statement");
                currentConnEnv.getSession().addPreparedStatement(i,ps);

                // all we want callers to see are the warnings.
                SQLWarning w = ps.getWarnings();
                ps.clearWarnings();
                {if (true) return new ijWarningResult(w);}
    throw new Error("Missing return statement in function");
  }
View Full Code Here

        int holdType = utilInstance.getHoldability(theConnection);
        String c;
        Statement st = null;
        String sVal;
        ResultSet rs = null;
        SQLWarning warns;
    jj_consume_token(GET);
    if (jj_2_94(2)) {
      scrolling = jj_consume_token(SCROLL);
      scrollType = scrollType();
    } else {
      ;
    }
    if (jj_2_95(2)) {
      withtoken = jj_consume_token(WITH);
      holdType = holdType();
    } else {
      ;
    }
    jj_consume_token(CURSOR);
    c = identifier();
    jj_consume_token(AS);
    s = jj_consume_token(STRING);
                sVal = stringValue(s.image);
                try {
                        st = utilInstance.createStatement(theConnection, scrollType, holdType);
                        JDBCDisplayUtil.checkNotNull(st,"cursor");
                        st.setCursorName(c);
                        rs = st.executeQuery(sVal);
                        JDBCDisplayUtil.checkNotNull(rs,"cursor");
                        Session sn = currentConnEnv.getSession();
                        sn.addCursorStatement(c,st);
                        sn.addCursor(c,rs);
                } catch (SQLException e) {
                        if (rs!=null) rs.close();
                        if (st!=null) st.close();
                        {if (true) throw e;}
                }

                // all we want callers to see are the warnings.
                SQLWarning w1 = theConnection.getWarnings();
                SQLWarning w2 = st.getWarnings();
                SQLWarning w3 = rs.getWarnings();
                theConnection.clearWarnings();
                st.clearWarnings();
                rs.clearWarnings();
                warns = appendWarnings(w1,w2);
                {if (true) return new ijWarningResult(appendWarnings(warns,w3));}
View Full Code Here

      ;
    }
            if (iUsing!=null || sUsing!=null) { // parameters in use
                        String sUsingVal = null;
                        PreparedStatement psUsing;
                        SQLWarning warns = null;

                        haveConnection();

                        /*
        Steps:
 
View Full Code Here

    // Now that we've processed all SET statements (assuming no
    // severe exceptions), check for warnings and, if we had any,
    // note this in the SQLCARD reply object (but DON'T cause the
    // EXCSQLSET statement to fail).
    if (hadUnrecognizedStmt) {
      SQLWarning warn = new SQLWarning("One or more SET statements " +
        "not recognized.", "01000");
      throw warn;
    } // end if.

    return;
View Full Code Here

        moreData = false;
        return moreData;
      }
     
      // Send ResultSet warnings if there are any
      SQLWarning sqlw = (rs != null)? rs.getWarnings(): null;
      if (rs != null) {
        rs.clearWarnings();
      }

      // for updatable, insensitive result sets we signal the
      // row updated condition to the client via a warning to be
      // popped by client onto its rowUpdated state, i.e. this
      // warning should not reach API level.
      if (rs != null && rs.rowUpdated()) {
        SQLWarning w = new SQLWarning("", SQLState.ROW_UPDATED,
            ExceptionSeverity.WARNING_SEVERITY);
        if (sqlw != null) {
          sqlw.setNextWarning(w);
        } else {
          sqlw = w;
        }
      }
      // Delete holes are manifest as a row consisting of a non-null
      // SQLCARD and a null data group. The SQLCARD has a warning
      // SQLSTATE of 02502
      if (rs != null && rs.rowDeleted()) {
        SQLWarning w = new SQLWarning("", SQLState.ROW_DELETED,
            ExceptionSeverity.WARNING_SEVERITY);
        if (sqlw != null) {
          sqlw.setNextWarning(w);
        } else {
          sqlw = w;
View Full Code Here

              int updateCount, boolean alwaysSend, boolean sendWarn)
    throws DRDAProtocolException, SQLException
  {
    // instead of writing a chain of sql warning, we send the first one, this is
    // jcc/db2 limitation, see beetle 4629
    SQLWarning warning = null;
    SQLWarning reportWarning = null;
    try
    {
      if (stmt != null)
      {
        warning = stmt.getWarnings();
View Full Code Here

    @param theConnection the connection that may have warnings.
   */
  static public void ShowWarnings(PrintWriter out, Connection theConnection) {
      try {
    // GET CONNECTION WARNINGS
    SQLWarning warning = null;

    if (theConnection != null) {
      ShowWarnings(out, theConnection.getWarnings());
    }

View Full Code Here

TOP

Related Classes of java.sql.SQLWarning

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.