Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Catching Internal Exceptions
Catching Internal Exceptions [message #683400] Mon, 13 June 2011 17:05 Go to next message
AmFreak Missing name is currently offline AmFreak Missing nameFriend
Messages: 25
Registered: June 2011
Junior Member
Hi,

how can i catch Eclipse Link exceptions?
For example if i start my application and the server insn't running i get:

[EL Severe]: Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLNonTransientConnectionException: java.net.ConnectException: Fehler beim Herstellen der Verbindung zum Server localhost am Port 1527. Nachricht: Connection refused: connect.
Error Code: 40000
	at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)
	at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:319)
	at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:138)
	at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
	at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal(DatasourceAccessor.java:330)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.connectInternal(DatabaseAccessor.java:291)
	at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connect(DatasourceAccessor.java:418)
	at org.eclipse.persistence.sessions.server.ConnectionPool.buildConnection(ConnectionPool.java:167)
	at org.eclipse.persistence.sessions.server.ConnectionPool.startUp(ConnectionPool.java:453)
	at org.eclipse.persistence.sessions.server.ServerSession.connect(ServerSession.java:484)
	at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:640)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:235)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:394)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:185)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:242)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:230)
	at de.fh.stockgrabber.model.StockGrabberEntityManagerFactory.createEntityManager(StockGrabberEntityManagerFactory.java:104)
	at de.fh.stockgrabber.model.StockGrabberEditorModel.<init>(StockGrabberEditorModel.java:37)
	at de.fh.stockgrabber.project.model.ProjectsModel.<init>(ProjectsModel.java:40)
	at de.fh.stockgrabber.views.MainView.createPartControl(MainView.java:105)
	at org.eclipse.ui.internal.ViewReference.createPartHelper
        ..........
        [many more]


The code crashes when i try to create the EntityManager:
		try {
			em = StockGrabberEntityManagerFactory.createEntityManager();
			transaction = em.getTransaction();
			transaction.begin();
		} catch (Exception e) {
			System.exit(0);


The Exception is catched (the app exists), but it doesn't stop the output as seen above. So how can i handle this; or can't i cause it's an "Internal Exception"?
Re: Catching Internal Exceptions [message #683429 is a reply to message #683400] Mon, 13 June 2011 17:55 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Do you want to catch the exception, or just not have it logged?

You can turn off logging to not have the error logged, set the log level to OFF.

http://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging


James : Wiki : Book : Blog : Twitter
(no subject) [message #683443 is a reply to message #683400] Mon, 13 June 2011 17:55 Go to previous messageGo to next message
James is currently offline JamesFriend
Messages: 272
Registered: July 2009
Senior Member
Do you want to catch the exception, or just not have it logged?

You can turn off logging to not have the error logged, set the log level to OFF.

http://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging
--
James : http://wiki.eclipse.org/EclipseLink : http://en.wikibooks.org/wiki/Java_Persistence : http://java-persistence-performance.blogspot.com/
Re: (no subject) [message #683575 is a reply to message #683429] Tue, 14 June 2011 02:57 Go to previous message
AmFreak Missing name is currently offline AmFreak Missing nameFriend
Messages: 25
Registered: June 2011
Junior Member
Sry for the late reply Embarrassed
Im new to this whole database thing, but that was what i was missing.
So thank you, really appreciated!
(no subject) [message #683585 is a reply to message #683429] Tue, 14 June 2011 02:57 Go to previous message
AmFreak Missing name is currently offline AmFreak Missing nameFriend
Messages: 25
Registered: June 2011
Junior Member
Sry for the late reply :blush:
Im new to this whole database thing, but that was what i was missing.
So thank you, really appreciated!
Previous Topic:How can I get count of distinct left join subquery?
Next Topic:CriteriaBuilder.isEmpty on an ElementCollection vs. JPQL approach
Goto Forum:
  


Current Time: Tue Apr 23 06:15:42 GMT 2024

Powered by FUDForum. Page generated in 0.03315 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top