Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Logging & Exception Handling

Hi,

  I want to send eclipselink logging to Log4j logger. Is it possible to
create logging customizer and pass the log4j logger/appender (print writer)

  I am using Spring + EclipseLink integration. Currently database exception
are wrapped in spring DataAccessException. I want to display the sql error
code with the error message. I would like to use
SQLErrorCodeSQLExceptionTranslator and inject eclipselink (oracle db
specific) CustomSQLErrorCodesTranslation. Or use SQLErrorCodesFactory to get
the SqlErrorCode and wrapped in a exception ....Any suggestions???

public void testDefaultInstanceWithNoSuchDatabase() {
		SQLErrorCodes sec =
SQLErrorCodesFactory.getInstance().getErrorCodes("xx");
		assertTrue(sec.getBadSqlGrammarCodes().length == 0);
		assertTrue(sec.getDataIntegrityViolationCodes().length == 0);
	}
	
	/**
	 * Check that a known database produces recognizable codes.
	 */
	public void testDefaultInstanceWithOracle() {
		SQLErrorCodes sec =
SQLErrorCodesFactory.getInstance().getErrorCodes("Oracle");
		assertIsOracle(sec);
	}

	private void assertIsOracle(SQLErrorCodes sec) {
		assertTrue(sec.getBadSqlGrammarCodes().length > 0);
		assertTrue(sec.getDataIntegrityViolationCodes().length > 0);
		// This had better be a Bad SQL Grammar code
		assertTrue(Arrays.binarySearch(sec.getBadSqlGrammarCodes(), "942") >= 0);
		// This had better NOT be
		assertFalse(Arrays.binarySearch(sec.getBadSqlGrammarCodes(), "9xx42") >=
0);
	}


OR 

EclipseLink team is already have some inbuilt support for it.

-- 
View this message in context: http://www.nabble.com/Logging---Exception-Handling-tp24167143p24167143.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top