#

Wednesday, February 1, 2012

Expresso Shots!


  • org.apache.commons.beanutils.BeanUtils are nice but they return almost everything as a String which is annoying.

    To get the value of a field use this or a variant of it: BeanUtilsBean2.getInstance().getPropertyUtils().getSimpleProperty();


  • c3Po Configurations for shared hosted environments


    Connection Pooling on Production Infrastructure


    On a shared hosted 3rd party environment, sometimes Connections Pooling can be a big mess to deal with. One more often than not ends up with dropped connections (inspite of reconnect=true). Connections that are in the Pool but no longer honoured by the database itself, which results in such situations also among others. The issues with DBCP are worse than c3po, but they exist everywhere. Worse, in a shared hosted environment you do not have access to the Database as root and you don't have access to anything but whats in your application.

    Exceptions


    Some of the exceptions are of the following nature:

    Caused by: org.hibernate.TransactionException: JDBC begin failed:
    ...
    Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
    ...
    INFO [com.mchange.v2.c3p0.impl.NewPooledConnection] [c3p0] Exceptions occurred while trying to close a PooledConnection's resources normally.
    INFO [com.mchange.v2.c3p0.impl.NewPooledConnection] [c3p0] NewPooledConnection close Exception.
    com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communications link failure during rollback(). Transaction resolution unknown.


    Solution
    I wrote a script that automated the process of testing various combination's (certain key params), and then I fine tuned it manually. It was heuristic, and there may be other combination's but this really works well and fast. It is reliable and has proven good on several projects of that nature. I have my theory on why it works, but because the nature of determination was heuristic, I don't think its worth delving into.





























    true
    false

    ${db.credential.username}
    ${db.credential.password}






No comments:

Post a Comment