Monday, September 7, 2009

setting up datasource in tomcat & glassfish appserv

Notes to setup mysql datasource in tomcat/sunappserv (for my cs9323 assignment):

1. copy mysql-connector-java-5.1.8-bin.jar to c:\\tomcat6\lib or c:\\sun\appserv\lib

2. Add the following section to c:\\tomcat6\conf\context.xml

For glassfish, go to http://localhost:4848 and create a pool under 'Resource/Connection Pools' then create a jdbc resource called 'jdbc/mydb' in 'Resources/JDBC Resouces'. (you need to specific host,port, user, pass,db in the pool settings)

3. Under webcontent\META-INF, edit context.xml to include the following section:



Alternatively, this can be done via adding the following section into WEB-INF/web.xml:



4. for tomcat, use the following code to do the lookup:


For glassfish:

No comments: