Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

Werner Joerling

Ranch Hand
+ Follow
since Mar 23, 2003
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Werner Joerling

Hello Paul,

so far I understand.
Your tips help me a lot. Thanks.

Now considering the applciation you have described it sounds like a stand alone desktop application. If it is, why are you using a connection pool? You only need a maximum of one connections.

You are right.
I'm using a connection pool because Hibernate does it by default.
It uses a built-in connection pool. But in the the documentation the
built-in conn pool is not recommended for production use. It has the disadvantage, that the connections are not kept alive and exceptions are thrown after timeout. (I do not know how to reconnect).
Therefore I'm using the c3p0 conn pool. (It's the first one in the list of recommended conn pools). This conn pool keeps the connections alive. (One can see this in the log). I configured min-size and max-size of the conn pool as 1.

<property name="c3p0.min_size">1</property>
<property name="c3p0.max_size">1</property>

I do not know, how to use hibernate without a conn pool.
And I do not know how to solve the timeout problem myself. (My only idea is to send periodically a query, which has to be as cheap as possible).


[ December 12, 2006: Message edited by: Werner Joerling ]

Originally posted by Paul Sturrock:

One way would be to validate the login credentials when you get them (I'm not 100% sure why you wouldn't do this anyway - if you don't do this, why get them at all?). All you need to do is try to directly create a Connection with these credentials and catch the SQLException if one is thrown. You could parse the Exception to make sure it is a permissions exception, but since any SQLException when you create a connection amounts to the same thing (i.e. you can't connect) I'm not sure this matters.

The credentials are needed to authenticate and authorize the user against the database. Hibernate or more precisely the connection pool needs them to get the connections. That's the reason for getting the credentials. Furthermore the credentials are user-specific. I do not want to publish shared login data in a common readable configuration file.

Because the connection pool will try to connect the database, I think it must be able to detect failing login data and to come up with an appropriate message (therefore we have the SQL return codes), instead of retrying to connect over and over again and at last to come up with an unspecified connection error.

Why should I get an useless JDBC connection only to verify the credentials? It's hibernate's and the connection pool's task.

The most database tools I know, come up with an error message in case of failing login data. Why can I not do so?

Thanks for the answer.



Originally posted by Balaji Loganathan:
It is a not good way to use the user entered credentials for connecting to database directly. Of course you will get an error message after a long time bcos the class to get a connection to db.

Thank you Balaja,

can you explain me why this is not a good way?



in my hibernate.cfg.xml file I leave the properties "hibernate.connection.username" and "hibernate.connection.password" empty.
My application (a gui dialog) asks the user at startup time for the login data. (For your interest: I'm using the c3p0 connection pool.)
In case of a correct login all works fine.
In case of a wrong login the application resumes as usual, but comes after a long time with the java.sql.SQLException: "Connections could not be acquired from the underlying database!" caused by
com.mchange.v2.resourcepool.CannotAcquireResourceException: "A ResourcePool could not acquire a resource from its primary factory or source."

My question: How can I detect the wrong login earlier?
I can't explain the users why they should wait as long for the error message.
They want to have an immediate message like "Wrong password/username".

Ho can I realize this behavior?



in May 2004 I passed the SCJD.
I got the certificate and I read the detailed certification results.
But I do not remember them and I do not remember WHERE I read them.
Did I receive an e-mail or is the a database where I looked for them?
I cannot find a printed copy, and I cannot inspect my old e-mails
because a few weeks ago, my harddisk crashed and I lost all my data.

Please, can you tell me from where you got the detailed results?

Best regards

14 years ago
Hello friends,

this morning I passed the SCWCD 1.4 exam.

My weakest results (under the limit of 62%) I got in the sections

building a custom tag library: 40%
building JSP Pages using tag libraries: 50%
building JSP pages using the expression language (EL): 60%

This tells me, where I didn't learn enough.

For my preparation I used the great SCWCD Exam Study Kit (the old edition from 2003, covering Servlet 2.3 and JSP 1.2). It mainly lacks JSTL, EL, Simple Tags, and some J2EE-Patterns. I know, now there is a new edition, but I saved the money and tried the exam without buying a second book.

Beyond this book I used only free (zero-cost) material, the Servlet, JSP and JSTL specs, and the free mock exams at

If I would have learned more precisely custom tags, JSTL and EL, my result would have been nicer.

Next I will prepare for the SCBCD.

Best regards


[ August 15, 2005: Message edited by: Werner Joerling ]

Originally posted by Baris Dere:

How did you implement locking mechanism?

I did the locking mechanism similar to that in Mehran Habibi's book. There isn't a lock manager, but rather a

intended to store the locked records.
All record access methods (read, find, create, delete, update) in the Data class are synchronized by the method modifier 'synchronized'.
('create' and 'delete' aren't really implemented, they simply throw UnsupportedOperationException).
The lock methods (lock, unlock, isLocked) are using synchronized blocks

and the 'unlock' mehod calls

when recNo has been removed.
The single record access methods (read, update, delete) throw IllegalStateException if the recNo isn't locked.
The bulk record access method 'find' uses lock/read/unlock inside a loop over all records and skips deleted records.
There is a middle tier (locally or remotely accessible) between the clients
and the DBMain interface that implements the high level methods 'book' and 'search' and ensures the correct use of the lock/unlock protocol (db is of type DBMain).

[ May 12, 2004: Message edited by: Werner Joerling ]
16 years ago
Hi all,
just I got my result. Of course I'm happy to have passed but the score is disappointingly low, especially the GUI section.
Furthermore I waited for my result since March 29.
Here are images of my GUIs. Can someone explain me what is wrong with them?

Thanks to all here.
16 years ago

Originally posted by Vinay Shukla:
is that par for the course in Brussels?

Hi Vinay,
I think 3500 EUR/Month is ok.
Werner (M´┐Żnster, Germany)
16 years ago

Originally posted by Paresh Gandhi:
Can some one please help me? Here is my background

Hi Paresh,
where do you live/work?
16 years ago
does anybody know what's the matter at Sun?
I uploaded my jar-file on March 28 and took my essay exam on March 29 and now I'm waiting nearly five weeks for the result. The last "SCJD passed" message in the exam results forum is from April 11.
[ May 01, 2004: Message edited by: Werner Joerling ]
Hello HaoZhe,
the FAQ at says:

Your exam results will show up in the Certification database within 4 weeks after taking the essay at Prometric.

I'm waiting two weeks now.

Originally posted by Werner Joerling:

... there is neither an exception, nor a popup, but changes aren't persistent ...

I modified my NIO solution and now changes are made persistant on smbfs network drives, too.
But I made another observation. W2K does not update the last-modified-date/time of the database file on local drives.


Originally posted by Morgan Bath:
NIO doesnt work?? Seemed to work just fine for me

Please see:
My solution seems to work similar. I do not access overlapping regions
and I could observe it only with samba/Windows network drives and Windows as client.
The IO exception only appears on WinXP (together with an OS popup). With Win2K there is neither an exception, nor a popup, but changes aren't persistent.
[ February 13, 2004: Message edited by: Werner Joerling ]
during my tests I could observe that NIO does not work correctly when the database file resides on a network drive. In some constellations changes do not get persistent.
Maybe that is the reason to exclude NIO. But I will use it anyway.
[ February 13, 2004: Message edited by: Werner Joerling ]