This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Services and the fly likes Web service and JApplet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Web service and JApplet" Watch "Web service and JApplet" New topic
Author

Web service and JApplet

maja neskovic
Ranch Hand

Joined: Apr 28, 2010
Posts: 134
I have made one JApplet connected with MySQL database. I run it in a web page using one php file to write in a database. I would like to use a Web service instead of that php file to do the recording. Does anybody have any advice about this? I'm beginner in working with Web services and any help would be appreciated.

Php file looks like this (it gets only one parameter from JApplet and writes it in the database):
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
First of all, enumerate the operations you want your web service to support. Then write a Java class with one method for each of the operations. Finally, annotate the class with @WebService and you should be done!
What server do you want to use to run the web service in? Each type of server has, more or less, different ways of setting up access to a database.
If you want to set up database access from your application and not involve the server, then I can recommend:
- Plain JDBC.
Slightly verbose, as far as the code you have to write is concerned.
- Spring JDBC templates.
Nice and easy for simple applications. You will still issue plain SQL queries.
- Some JPA persistence provider, such as EclipseLink or Hibernate.
If you need ORM.

If you use Spring Roo to create your entity classes, then you get persistence with ORM "almost free" with very little work. Personally, I feel it is definitely worth the effort to do one or two tutorials on Spring Roo just to avoid writing DAOs and entity classes.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
maja neskovic
Ranch Hand

Joined: Apr 28, 2010
Posts: 134
Thank you for this explanation. I guess that JDBC would be ok to use. I'll try to do this and report for results.
 
Consider Paul's rocket mass heater.
 
subject: Web service and JApplet
 
Similar Threads
Pass parameter from JApplet to php file using POST method
Java Applet unable to use a PHP page to store a cookie
AJAX method
Writing to a web server
No connection to database from JApplet on Web page