Friday, December 01, 2006

Sun Java Application Server - MySQL : Connection Pooling HOWTO

Once in a while I come up with some tech howto. The last one being "HOWTO set XMMS current song as you IM status".

This time it is...


MySQL Connection Pooling Step-by-Step HOWTO

  • Make sure U have the mysql.jar file with U. It contains the mysql driver.
  • Your Sun Java Application Server (SJAS) folder looks like this

drive:\Sun\AppServer\ i will refer to this location as J2EE_HOME

  • Now copy the mysql.jar to J2EE_HOME\ant\lib directory
  • Start the server
  • Open the admin consolehttp://localhost:4848/
  • Login using the default uname/passwd

uname: admin

passwd: adminadmin

  • Click on : Application Server => JVM Settings tab => Path Settings tab
  • Now paste the following line: ${com.sun.aas.antLib}/mysql.jar in the textarea labeled as "Classpath Suffix"
  • Click on Save. Close the admin console.
  • Restart the server.
  • Open the admin console (http://localhost:4848/) again.
  • Expand the Resources node
  • Expand the JDBC sub-node
  • Click on Connection Pools
  • Click on New
  • Fill up the fields as follows:

Name: mysqlpool

Datasource Classname: com.mysql.jdbc.jdbc2.optional.MysqlDataSource

Resource Type: javax.sql.DataSource

Do not modify rest of the fields.

  • Now add following properties by clicking on "Add Property" at the bottom of the form:

DatabaseName : OnlineBankingSystem

User : admin (your mysql username)

Password : admin (your mysql password)

  • Click on save. You will see "New values successfully saved"
  • Now, Click on Ping. If you get a "Ping succeeded." then be happy :D
  • Now is the last step. click on the JDBC Resources node.
  • Click on New.
  • Fill up the fields as follows:

JNDI Name: mysql

Pool Name: mysqlpool

  • Click on Save. Thats it! We r done ! :D
  • Your mysql connection pool is now ready to accept requests to the database. It is referred to as just "mysql" from within the EJB and JSP (its JNDI Name remember, :-? ).
  • And of course, I wish U all the Best ! :D
    Lemme know soon wat happened and if it helped. :D

5 comments:

Anonymous said...

pooossssyyy cn ya please put up a brand new, nice, interesting post? am borED :P
and make it english please, not techese :D

Pushkar said...

:D
aap ki tariff ?

Anonymous said...

zarooor! sho man! aap chaho jitni tareef (as opposed to tariff) karlo :P

mephistee

Pushkar said...

bevakoof ladkee...

about:blank said...

shuddup...derez no such thing...staap yer bakwass (talkin thru d ass)!

listen to this quote i found:

"The most exciting phrase to hear in science, the one that heralds new discoveries, is not 'Eureka!' but 'That's funny ...'"
Isaac Asimov