This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes How to send a J2EE web application linked to mysql database to others? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "How to send a J2EE web application linked to mysql database to others?" Watch "How to send a J2EE web application linked to mysql database to others?" New topic
Author

How to send a J2EE web application linked to mysql database to others?

Suvojit Chakraborty
Ranch Hand

Joined: Nov 10, 2009
Posts: 62
    
    1
HI ALL,

I have made a simple J2EE web application which has few pages which pick up and displays data from mysql database. I need to send this project to someone as a proof of my project work. How do I send it?
I am using Netbean6.5 IDE and mysql database. I have included the driver in the library folder of the web project in netbeans. Now I want to know that if I zip the project and mail it to someone, will he be able to run my project. And how to the mail the database in mysql?

Please suggest

thanks
Soumyajit Hazra
Ranch Hand

Joined: Jun 26, 2007
Posts: 136
It can be done in different way. You can create a script file (.sql) which will do all the database specific job like creating tables and loading sample data. Package your web application as war file. And write a java file which calls the .sql file and deploy the war file. Create a jar like setup.jar and put the java file there, change the Manifest.MF file of the jar so that if some one clicks the jar it loads the db and then deploy the webapp. Providing a readme file will be a good idea. Instead of jar file you can create a .bat file in which also do the same. Or you can work with ANT script to do all the things starting from database set up to deploying the web application.


Java Programmer | SCJP 1.5 | SCWCD 1.4
Suvojit Chakraborty
Ranch Hand

Joined: Nov 10, 2009
Posts: 62
    
    1
thanks for reply but I could not digest much. Will it not work if I just create a zip containing the website's folder and the mysql's data snapshot. Is there any way I could create a snapshot of the data???

Please specify me detailed steps. I have no idea as to how to create this .sql sript file etc....

thanks for help
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

That could work but then you're assuming that (s)he has mysql installed and that it's bound to the same port number.

What you could do, but it's very overkill, is create a virtual machine, install mysql, appserver and your app. Create the necessary services and give him/her that.
Or just open your ports for the app, mail the code and direct him/her to the website on your machine.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Soumyajit Hazra
Ranch Hand

Joined: Jun 26, 2007
Posts: 136
If you send a snapshot then he/she have to look into it and manually entry the data into to database and before that the database need to be locally created. That's why I told about the .sql file which will contain the sql commands to create and load the test data. And the person whom you are sending the data if unaware of sql commands then it's difficult. So if you put the create and insert sql commands in a file and save it with .sql extension he/she can directly run it. But if your database is available in some server and the person whom you are sending the code have permission to access then all these database stuff not required. Only the webapp need to be deployed. In the same way if the app server is running in network and he/she is in the same network group then nothing required, you need to only send the link of your welcome page.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42031
    
  64
If it's just a small project, why use MySql at all? Use Hsqldb and ship the complete DB with the application - no setup, no nothing.


Ping & DNS - my free Android networking tools app
Soumyajit Hazra
Ranch Hand

Joined: Jun 26, 2007
Posts: 136
Use Hsqldb and ship the complete DB with the application - no setup, no nothing
Completely agreed to Ulf. But still if we have to do it with MYSQL/Oracle then what will be the approach? I had also face this type of problem. Is there any 3rd party packaging tool available? Or we need to follow any of the above approach.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You either follow the above approach, or expose your DB externally, or send a VM image, or embed the DB--the best solution.
 
jQuery in Action, 2nd edition
 
subject: How to send a J2EE web application linked to mysql database to others?