Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

January 9, 2010

Everything is dead these days


Sounds morbid, but, really, in last few weeks everything died :)

As a ColdFusion developer most noticeable to me was spree of articles & blogs which tried to explain how CF is dead (or is about to die). But that's something I used to. Each time new CF Server comes out, "CF-is-dead wave" hit the coast. What really surprised me was that everything else died.

Few days ago, I read an "old" (for some reason it became popular again) article how UML died and 13 reasons why is so. According to author, this technology is already dead. After reading it, my only question was: What is an alternative? Read a blog, read dozens of comments and no one suggested what can be an alternative to this.

November 12, 2008

Developing ColdFusion Extensions in Java

To make this short and effective:

1. You cannot reload CFX developed in Java without server restart. Empirically proven and confirmed by other CF developers (as some ppl claim, even by Adobe tech support)
ref: http://dreamweaverforum.info/advanced-techniques/78901-how-reload-java-cfx-without-restarting-coldfusion.html

2. Article to read to get into this subject fast and "good enough"
http://www.intermedia.net/support/coldfusion/cf5docs/Developing_ColdFusion_Applications/CFXTags4.html

3. Example
import com.allaire.cfx.*;

public class test implements CustomTag {

public void processRequest(Request request, Response response) throws Exception {
// TODO Auto-generated method stub
String strName = request.getAttribute( "NAME" );
response.write( "Cao, " + strName );

Query qr = request.getQuery();

if ( qr == null )
{
throw new Exception(
"Missing QUERY parameter. " +
"You must pass a QUERY parameter in "+
"order for this tag to work correctly." ) ;
}

int i=1,j=1;
while(i<=qr.getRowCount()){ j=1; response.write(" "); while(j<=qr.getColumns().length){ response.write(qr.getData(i, j)+" | "); j++; } i++; } } }


Voila! Now you know everything :)))

January 15, 2007

Tomcat 5.x - MySQL Bug: "Cannot get a connection, pool exhausted"

A web application has to explicetely close ResultSet's, Statement's, and Connection's. Failure of a web application to close these resources can result in them never being available again for reuse, a db connection pool "leak". This can eventually result in your web application db connections failing if there are no more available connections.

There is a solution to this problem. The Jakarta-Commons DBCP can be configured to track and recover these abandoned dB connections. Not only can it recover them, but also generate a stack trace for the code which opened these resources and never closed them.

To configure a DBCP DataSource so that abandoned dB connections are removed and recycled add the following attribute to the Resource configuration for your DBCP DataSource:

removeAbandoned="true"
When available db connections run low DBCP will recover and recyle any abandoned dB connections it finds. The default is false.

Use the removeAbandonedTimeout attribute to set the number of seconds a dB connection has been idle before it is considered abandoned.

removeAbandonedTimeout="60
The default timeout for removing abandoned connections is 300 seconds.

The logAbandoned attribute can be set to true if you want DBCP to log a stack trace of the code which abandoned the dB connection resources.

logAbandoned="true"
The default is false.

Abstract taken from
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto

Additional information:
http://dev.mysql.com/doc/refman/4.1/en/connector-j-usagenotes-j2ee.html#connector-j-usagenotes-tomcat