Ergebnis 1 bis 9 von 9

Thema: DatabaseAccessor not connected and Eingabe/Ausgabe-Fehler

  1. #1
    mik
    mik ist offline Neuer Benutzer
    Registriert seit
    12.09.2011
    Beiträge
    6

    Standard DatabaseAccessor not connected and Eingabe/Ausgabe-Fehler

    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(connec tionProperties);
    // 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

    You can download a ZIP with the files mentioned above HERE -> http://www.klische.ch/files.zip (since the upload of files on this page won't work

    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

  2. #2
    ads
    ads ist offline Super-Moderator
    Registriert seit
    08.02.2006
    Ort
    MD
    Beiträge
    4.056

    Standard

    Ok, I don't want to try your test case, simply because I don't have the same setup like you have (database, java, database version, data in your database, ect).

    But: Can you try to execute all these steps directly in psql and see, if this works?
    Xandrian: Kurz gesagt: Du hast ein falsches Konzept und willst nicht auf ads hören

    Jetzt NEU: PostgreSQL - Datenbankpraxis für Anwender, Administratoren und Entwickler

    PostgreSQL Service & Support

  3. #3
    mik
    mik ist offline Neuer Benutzer
    Registriert seit
    12.09.2011
    Beiträge
    6

    Standard

    Zitat Zitat von ads Beitrag anzeigen
    Ok, I don't want to try your test case, simply because I don't have the same setup like you have (database, java, database version, data in your database, ect).
    But: Can you try to execute all these steps directly in psql and see, if this works?
    You mean if I execute the SELECT Stmt with a Query Tool on the database? This works fine, there is no problem. The problem is that I think, that the Eclipselink-Layer try to reload data from database and somehow the session expires during that process.

  4. #4
    ads
    ads ist offline Super-Moderator
    Registriert seit
    08.02.2006
    Ort
    MD
    Beiträge
    4.056

    Standard

    How long does it take to load the data from the database?
    Xandrian: Kurz gesagt: Du hast ein falsches Konzept und willst nicht auf ads hören

    Jetzt NEU: PostgreSQL - Datenbankpraxis für Anwender, Administratoren und Entwickler

    PostgreSQL Service & Support

  5. #5
    mik
    mik ist offline Neuer Benutzer
    Registriert seit
    12.09.2011
    Beiträge
    6

    Standard

    Zitat Zitat von ads Beitrag anzeigen
    How long does it take to load the data from the database?
    About... 2 or 3 Seconds to load a set of approx. ~2200 Records. And after that it may take several minutes to browse through them manually. Thing is: Sometimes i fetch the 2200 Records press quickly after the fetch the button to iterate through the records and sometimes it takes 2 Seconds until i get the error, and sometimes it takes... 10 seconds or so (and the fetching time of the initial load of the records is still the same).

    I read somewhen something about a 15 Second Session timeout (or was is the connection timeout). I sure hit that limit somewhen, but then the error should appears very predictable after this amount of time. And it do not behave like this...

    The Java-Code that throws the error inside EclipseLink library is the following one:
    Code:
                // If the connection is no longer connected, it may have timed out.
                if (this.datasourceConnection != null) {
                    if (shouldCheckConnection && !isConnected()) {
                        if (this.isInTransaction) {
                            throw DatabaseException.databaseAccessorNotConnected();
                        } else {
                            reconnect(session);
                        }
                    }
                } else {
                    // If ExternalConnectionPooling is used, the connection can be re-established.
                    if (this.usesExternalConnectionPooling) {
                        reconnect(session);
                        session.postAcquireConnection(this);
                        currentSession = session;
                    } else {
                        // HERE IT HAPPENS!!!
                        throw DatabaseException.databaseAccessorNotConnected();
                    }
                }
    Obviously the "usesExternalConnectionPooling" seems to be false. But why this is I don't know. If it's something I have to setup in the database environment (config), on level JPA/Eclipselink or somewhere. I don't know...

  6. #6
    ads
    ads ist offline Super-Moderator
    Registriert seit
    08.02.2006
    Ort
    MD
    Beiträge
    4.056

    Standard

    The database has no connection timeouts which disconnect you after only some seconds.
    my bet is the connection pooler - maybe it is using different connections for each query or has very small timeout settings.
    Xandrian: Kurz gesagt: Du hast ein falsches Konzept und willst nicht auf ads hören

    Jetzt NEU: PostgreSQL - Datenbankpraxis für Anwender, Administratoren und Entwickler

    PostgreSQL Service & Support

  7. #7
    mik
    mik ist offline Neuer Benutzer
    Registriert seit
    12.09.2011
    Beiträge
    6

    Standard

    Zitat Zitat von ads Beitrag anzeigen
    The database has no connection timeouts which disconnect you after only some seconds.
    my bet is the connection pooler - maybe it is using different connections for each query or has very small timeout settings.
    Hmm, okay... Connection Pooler sounds logical.

    And how can I configure this connection pooler or the timeout settings of this? Since I use windows I just downloaded a Windows Installer for PostgreSQL and pressed next, next, next finish. I have no advanced knowledge how to configure PostgreSQL. Its there an UI to configure this Connection Pooler / Connection Timeouts? Or must this be resolved in postresql.conf file?

  8. #8
    ads
    ads ist offline Super-Moderator
    Registriert seit
    08.02.2006
    Ort
    MD
    Beiträge
    4.056

    Standard

    The connection pooler comes with Java, not with PostgreSQL.
    Therefore you have to solve this problem in Java.

    I'm sorry, I avoid Java where possible, can't help you here.
    Xandrian: Kurz gesagt: Du hast ein falsches Konzept und willst nicht auf ads hören

    Jetzt NEU: PostgreSQL - Datenbankpraxis für Anwender, Administratoren und Entwickler

    PostgreSQL Service & Support

  9. #9
    mik
    mik ist offline Neuer Benutzer
    Registriert seit
    12.09.2011
    Beiträge
    6

    Standard

    Okay, then I'll try to get more information about the Java Connection Pooling mechanisms. Also "New-Land" for me...
    Thanks for your help so far!

Ähnliche Themen

  1. psql history Ausgabe
    Von rolf.schaufelberger im Forum Allgemeines
    Antworten: 0
    Letzter Beitrag: 21.03.2011, 10:23
  2. XML-Ausgabe?
    Von karl_ha im Forum Allgemeines
    Antworten: 9
    Letzter Beitrag: 18.02.2010, 09:19
  3. Spalten Ausgabe
    Von bastiiie im Forum Andere Datenbanken
    Antworten: 6
    Letzter Beitrag: 12.03.2009, 10:51
  4. Eingabe von Sonderzeichen
    Von Alfredo im Forum Allgemeines
    Antworten: 1
    Letzter Beitrag: 30.01.2009, 09:44
  5. Hierarchische Ausgabe von Datensätzen
    Von cuthbert im Forum Allgemeines
    Antworten: 1
    Letzter Beitrag: 20.07.2007, 12:40

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

Links: Tobias Bauer - IT- und Funkdienstleistungen   -   Bilderrahmen-kaufen.de - Der Onlineshop für Bilderrahmen & Fotorahmen   -   Funkforum