Java Code Examples for java.sql.SQLWarning#getMessage()

The following examples show how to use java.sql.SQLWarning#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GFXDServiceImpl.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private GFXDExceptionData gfxdWarning(SQLWarning warnings)
    throws SQLException {
  GFXDExceptionData warningData = new GFXDExceptionData(
      warnings.getMessage(), warnings.getSQLState(), warnings.getErrorCode());
  ArrayList<GFXDExceptionData> nextWarnings = null;
  SQLWarning next = warnings.getNextWarning();
  if (next != null) {
    nextWarnings = new ArrayList<GFXDExceptionData>();
    do {
      nextWarnings.add(new GFXDExceptionData(next.getMessage(), next
          .getSQLState(), next.getErrorCode()));
    } while ((next = next.getNextWarning()) != null);
  }
  //GFXDExceptionData sqlw = new GFXDExceptionData(warningData);
  //sqlw.setNextWarnings(nextWarnings);
  if (nextWarnings != null) {
    warningData.setReason(warningData.getReason() + nextWarnings.toString());
  }
  return warningData;
}
 
Example 2
Source File: GFXDServiceImpl.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private GFXDExceptionData gfxdWarning(SQLWarning warnings)
    throws SQLException {
  GFXDExceptionData warningData = new GFXDExceptionData(
      warnings.getMessage(), warnings.getSQLState(), warnings.getErrorCode());
  ArrayList<GFXDExceptionData> nextWarnings = null;
  SQLWarning next = warnings.getNextWarning();
  if (next != null) {
    nextWarnings = new ArrayList<GFXDExceptionData>();
    do {
      nextWarnings.add(new GFXDExceptionData(next.getMessage(), next
          .getSQLState(), next.getErrorCode()));
    } while ((next = next.getNextWarning()) != null);
  }
  //GFXDExceptionData sqlw = new GFXDExceptionData(warningData);
  //sqlw.setNextWarnings(nextWarnings);
  if (nextWarnings != null) {
    warningData.setReason(warningData.getReason() + nextWarnings.toString());
  }
  return warningData;
}
 
Example 3
Source File: JdbcUtil.java    From iaf with Apache License 2.0 6 votes vote down vote up
public static void warningsToXml(SQLWarning warnings, SaxElementBuilder parent) throws SAXException {
	if (warnings!=null) {
		try (SaxElementBuilder elementBuilder = parent.startElement("warnings")) {
			while (warnings!=null) {
				try (SaxElementBuilder warning = elementBuilder.startElement("warning")) {
					warning.addAttribute("errorCode",""+warnings.getErrorCode());
					warning.addAttribute("sqlState",""+warnings.getSQLState());

					String message=warnings.getMessage();
					
	 				Throwable cause=warnings.getCause();
					if (cause!=null) {
						warning.addAttribute("cause",cause.getClass().getName());
						if (message==null) {
							message=cause.getMessage();
						} else {
							message=message+": "+cause.getMessage();
						}
					}
					warning.addAttribute("message",message);
				}
			}
		}
	}
}
 
Example 4
Source File: BaseSQLQueryFactory.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
protected void logWarnings(PreparedStatement pstmt)
throws SQLException {
  SQLWarning warning = pstmt.getWarnings();
  while (warning != null) {
    String message = warning.getMessage();
    //String sqlState = warning.getSQLState();
    int errorCode = warning.getErrorCode();
    Log.getLogWriter().warning("While executing prepared statement: " + pstmt
                             + " got error code: " + errorCode
                             + " for: " + message);
    warning = warning.getNextWarning();
  }
}
 
Example 5
Source File: BaseSQLQueryFactory.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
protected void logWarnings(PreparedStatement pstmt)
throws SQLException {
  SQLWarning warning = pstmt.getWarnings();
  while (warning != null) {
    String message = warning.getMessage();
    //String sqlState = warning.getSQLState();
    int errorCode = warning.getErrorCode();
    Log.getLogWriter().warning("While executing prepared statement: " + pstmt
                             + " got error code: " + errorCode
                             + " for: " + message);
    warning = warning.getNextWarning();
  }
}
 
Example 6
Source File: JdbcUtil.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Deprecated
public static XmlBuilder warningsToXmlBuilder(SQLWarning warnings) {
	if (warnings!=null) {
		XmlBuilder warningsElem = new XmlBuilder("warnings");
		while (warnings!=null) {
			XmlBuilder warningElem = new XmlBuilder("warning"); 
			warningElem.addAttribute("errorCode",""+warnings.getErrorCode());
			warningElem.addAttribute("sqlState",""+warnings.getSQLState());
			String message=warnings.getMessage();
			
			// getCause() geeft unresolvedCompilationProblem (bij Peter Leeuwenburgh?)
				Throwable cause=warnings.getCause();
			if (cause!=null) {
				warningElem.addAttribute("cause",cause.getClass().getName());
				if (message==null) {
					message=cause.getMessage();
				} else {
					message=message+": "+cause.getMessage();
				}
			}
			
			warningElem.addAttribute("message",message);
			warningsElem.addSubElement(warningElem);
			warnings=warnings.getNextWarning();
		}
		return warningsElem;
	}
	return null;
}
 
Example 7
Source File: SplitRegionRowCountOperationIT.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test
public void testSplitAgain() throws Exception {
    TestConnection conn = spliceClassWatcher.getOrCreateConnection();
    CallableStatement callableStatement = conn.prepareCall("call SYSCS_UTIL.SYSCS_SPLIT_TABLE_AT_POINTS(?,?,?)");
    callableStatement.setString(1,SCHEMA);
    callableStatement.setString(2,"A");
    callableStatement.setInt(3,12);
    callableStatement.execute();
    SQLWarning warning = callableStatement.getWarnings();
    String wm = warning.getMessage();
    String ewm = "Ignore splitkey '12' because it is equal to a startkey";
    Assert.assertEquals(wm, ewm);
}