use of java.sql.SQLWarning in project jdk8u_jdk by JetBrains.
the class SQLWarningTests method test14.
/**
* Validate that the ordering of the returned SQLWarning is correct using
* traditional while loop
*/
@Test
public void test14() {
SQLWarning ex = new SQLWarning("Warning 1", t1);
SQLWarning ex1 = new SQLWarning("Warning 2");
SQLWarning ex2 = new SQLWarning("Warning 3", t2);
ex.setNextWarning(ex1);
ex.setNextWarning(ex2);
int num = 0;
SQLWarning sqe = ex;
while (sqe != null) {
assertTrue(warnings[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextWarning();
}
}
use of java.sql.SQLWarning in project jdk8u_jdk by JetBrains.
the class SQLWarningTests method test6.
/**
* Create SQLWarning with message, SQLState, and Throwable
*/
@Test
public void test6() {
SQLWarning ex = new SQLWarning(reason, state, t);
assertTrue(ex.getMessage().equals(reason) && ex.getSQLState().equals(state) && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == 0);
}
use of java.sql.SQLWarning in project adempiere by adempiere.
the class DB method printWarning.
// isRemoteProcess
/**************************************************************************
* Print SQL Warnings.
* <br>
* Usage: DB.printWarning("comment", rs.getWarnings());
* @param comment comment
* @param warning warning
*/
public static void printWarning(String comment, SQLWarning warning) {
if (comment == null || warning == null || comment.length() == 0)
throw new IllegalArgumentException("Required parameter missing");
log.warning(comment);
//
SQLWarning warn = warning;
while (warn != null) {
StringBuffer buffer = new StringBuffer();
buffer.append(warn.getMessage()).append("; State=").append(warn.getSQLState()).append("; ErrorCode=").append(warn.getErrorCode());
log.warning(buffer.toString());
warn = warn.getNextWarning();
}
}
use of java.sql.SQLWarning in project robovm by robovm.
the class OldConnectionTest method testClearWarnings.
// TODO clearWarnings is not supported
public void testClearWarnings() throws Exception {
SQLWarning w = conn.getWarnings();
assertNull(w);
Statement st = null;
try {
st = conn.createStatement();
st.execute("select animals from zoo");
fail("SQLException was not thrown");
} catch (SQLException e) {
assertNotNull(conn.getWarnings());
} finally {
try {
st.close();
} catch (SQLException ee) {
}
}
conn.clearWarnings();
w = conn.getWarnings();
assertNull(w);
try {
st = conn.createStatement();
st.execute("select monkey from zoo");
fail("SQLException was not thrown");
} catch (SQLException e) {
assertEquals("SQLite.Exception: error in prepare/compile", e.getMessage());
} finally {
try {
st.close();
} catch (SQLException ee) {
}
}
//Test for correct functionality
w = conn.getWarnings();
assertNotNull(w);
conn.close();
try {
conn.clearWarnings();
fail("Exception expected");
} catch (SQLException e) {
//ok
}
}
use of java.sql.SQLWarning in project robovm by robovm.
the class OldStatementTest method testClearWarnings.
public void testClearWarnings() throws SQLException {
Statement st = null;
try {
st = conn.createStatement();
st.execute("select animals from zoo");
} catch (SQLException e) {
// expected
} finally {
try {
st.close();
} catch (SQLException ee) {
}
}
try {
st = conn.createStatement();
st.clearWarnings();
SQLWarning w = st.getWarnings();
assertNull(w);
} finally {
try {
st.close();
} catch (SQLException ee) {
}
}
}
Aggregations