DatabaseAccessor not connected and Eingabe/Ausgabe-Fehler [message #727684] |
Wed, 21 September 2011 20:01 |
Mike Messages: 4 Registered: September 2011 |
Junior Member |
|
|
Hey all
I wrote an own java CRUD application, using PostgreSQL. I have now two serious problem and I cannot find a solution for them Both problems has todo with the database
connection.
But let me introduce shortly my application: It's a simple customer/contract management system (nothing special). It's possible to manage customers and related contracts.
A customer has several sub-objects like ID (I mean ID such as a passport), official documents (Permits) and the result is a contract document.
Now what is the problem? In my application there is a use-case that requires to search for customers and display their information (like address, name, ...) and also some
information from their sub-objects like ID-Number, Validity of e.g. the passport, and the validity of the official document attached to the customer. On the database
there are 3 tables for that (Person, Identification, Permit) and a fourth table that stores the contracts. I use the following code to search customers returning a result
set in the form of a List<Person>. It seems that when I iterate through these list, a "layer" in my whole stack tries to reload data from database (I thinks it's the
EclipseLink that tries to load additional information of a person).
And then it happens: exception-2.txt occures ([...]DatasourceAccessor.java:309[...])
The line of code that causes the problem can be found in DatasourceAccessor.java in the EclipseLink-Source! It's (wow what a surprise...):
throw DatabaseException.databaseAccessorNotConnected();
because the "if (this.usesExternalConnectionPooling)" seems to be false!
But why this is, I don't know and I was unable to find till now a solution.
The exception in the file exception-1.txt happens not often and also random! Also for this I have no solution. A lot of forum entries on the Internet I found that says
there is something wrong with the network, but since the Postgresql-Database is installed on my local PC I think it's not that problem. Also firewalls (windows and other
firewall-software) should not be an issue, since I deactivated them. What I found is a strange entry in the logfile of postgresqs says:
2011-09-21 20:52:42 CEST LOG: unerwartetes EOF auf Client-Verbindung
2011-09-21 20:52:42 CEST LOG: konnte Daten vom Client nicht empfangen: No connection could be made because the target machine actively refused it.
But why the target machine actively should refuse it? I don't know
Let me show also show you some code that selects the List of customers that I iterate:
@Override
public List<Person> searchCustomer(String[] searchItems, ECustomerSearchCriterion searchCriterion) throws SQLException
{
List<Person> returnListPerson = new ArrayList<Person>();
Query query = null;
int ctr = 0;
try {
entityManager = DBHelper.getInstance().getMainEntityManager(connectionProperties);
// Compose the Select Statement the old fashioned way:
// SELECT p FROM Person p WHERE p.personState = 1 AND p.personType = 'C'
// ... some Code with error handlings about the parameter
@SuppressWarnings("unchecked") List<Person> resultListPersons = query.getResultList(); //NOI18N
returnListPerson = resultListPersons;
}
catch (Exception e) {
throw new SQLException(e);
}
finally {
if (entityManager != null && entityManager.isOpen()) {
entityManager.close();
}
}
if (returnListPerson.isEmpty()) {
return null;
}
else {
return returnListPerson;
}
}
As you can see, nothing special! When this function returns there is no further database-access (from my side, like using EntityManager or something like that, ...). The
code happens after the call of this function is simply iterate through the returnListPerson and access the database objects in it (to display them).
A word about versions and libraries:
- Operating System: Windows 7 Ultimate English, 64bit
- Java-Version: 1.6.0_26 Java(TM) Runtime Environment (build 1.6.0_26-b03), Java HotSpot (TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
- NetBeans Development Environment 7.0 (Build 201104080000)
- Postgres-Java-Driver: postgresql-9.0-801.jdbc4.jar
- Javax-Persistence (JPA): javax.persistence_2.0.3v201010191057.jar
- Eclipselink: ecliselink.jar (MANIFEST.MF says "Implementation-Version: 2.3.0.v20110604-r9504
- Postgresql: select version(); says PostgreSQL 9.0.3, compiled by Visual C++ build 1500, 64-bit
So, that's what I can give you for information. I'm looking since a couple of weeks through the internet about this problem and haven't found a solution till now I
start to dispair about this problem
Hope you can help!
Greetings, Mike
-
Attachment: files.zip
(Size: 17.31KB, Downloaded 832 times)
|
|
|
Re: DatabaseAccessor not connected and Eingabe/Ausgabe-Fehler [message #728096 is a reply to message #727684] |
Thu, 22 September 2011 14:20 |
|
>> DBHelper.getInstance().getMainEntityManager(connectionProperties);
What does this do exactly and why? It seems you are getting a specific connection per request (not using a connection pool)??
Normally connection pooling is used.
You are also closing the EntityManager before returning the objects, as they have relationships that will need to be fetched, these will need to reconnect this closed entity manager.
Try using a connection pool, or use join fetching or a LoadGroup to instantiate everything you need before returning.
James : Wiki : Book : Blog : Twitter
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05605 seconds