THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
- Launch Eclipse. Select File --> New --> Project.
- Select Web --> Dynamic Web Project. Select Next.
- On the next screen give the name of the project as WebJDBC.
- Select default values for all other fields. Finally select Finish.
...
Code Block | ||||
---|---|---|---|---|
| ||||
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1" xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.2" xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0" xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2"> <sys:environment> <sys:moduleId> <sys:groupId>default</sys:groupId> <sys:artifactId>WebJDBC</sys:artifactId> <sys:version>1.0</sys:version> <sys:type>car</sys:type> </sys:moduleId> <sys:dependencies> <sys:dependency> <sys:groupId>console.dbpool</sys:groupId> <sys:artifactId>jdbc/userds<artifactId>userds</sys:artifactId> </sys:dependency> </sys:dependencies> </sys:environment> <context-root>/WebJDBC</context-root> <nam:resource-ref> <nam:ref-name>jdbc/userds</nam:ref-name> <nam:pattern> <nam:groupId>console.dbpool</nam:groupId> <nam:artifactId>jdbc/userds<artifactId>userds</nam:artifactId> <nam:name>jdbc/userds</nam:name> </nam:pattern> </nam:resource-ref> </web-app> |
- <sys:dependency>- The dependency element is to suggest the dependency of the application on the database pool. In our case we have jdbc/userds as a dependency module.
- <nam:resource-ref>- This element is used to map the JDBC connenction pool with a user defined name. In our case we have mapped jdbc/userds with jdbc/userds.
Deploy and Run
- Start the server within Eclipse.
- Right-click on WebJDBC project and select Run as – > Run on server.
- Once done the application will be deployed on the server.
- Launch the application with the following link http://localhost:8080/WebJDBC/
- Fill up the form with the a image location and name. The same name will be used while populating the database with the image data. Select Submit once done.
- If your image is successfully inserted into the database you will get a Congratulation message.
- To retrieve an image from the database launch the following portlet http://localhost:8080/WebJDBC/ImageDownload.jsp. Select submit once done.
- This will display the image in the browser