wood burning stoves 2.0*
The moose likes Java in General and the fly likes client-server based Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "client-server based Query" Watch "client-server based Query" New topic
Author

client-server based Query

Manish Sridharan
Ranch Hand

Joined: Jul 19, 2005
Posts: 64
Respected Members ,

I have been to make small project in which two or three system will acces the same program . the project is work as basic record keeping system which can be modified .
I m stuck at the point which way i design the system.
Should i use web based solution for it with the use of tomcat and some database or should i use some kind of socket programming to make the system work. if i use socket programming . it would be neccessary to implement the multi threading bcos it can happen one client is updating the value of the particular record and other is actually deleting the record.

i want to know do i also need the tomcat server in case of socket programming and doesnt database like mysql implements multithreading in itself....

Please answer these queries ASAP....

gaurav


Manish S.
Scheepers de Bruin
Ranch Hand

Joined: Jul 19, 2005
Posts: 99
The easiest way to implement a distributed application without having to worry about multi-threading is with a web app.

You do not need tomcat to implement the system with sockets, but there are WAY more to take into consideration when using sockets. You're basically going to have to create some form of server. You'll have to do handshaking on first connecting, then assign the speciffic app connecting to the server a new port number to connect on, so that other apps can use the first port for handshaking as well.

Then you'll have to implement threads to handle each instance's communication, a protocol for your apps to communicate...

If I were you, I'd rather implement the system using either servlets or jsp. It takes care of all of the above.


We're doomed!!<br />Yay!!!<br />No that's bad Girr!!<br />Yay!!!
Manish Sridharan
Ranch Hand

Joined: Jul 19, 2005
Posts: 64
Originally posted by Scheepers de Bruin:
The easiest way to implement a distributed application without having to worry about multi-threading is with a web app.

You do not need tomcat to implement the system with sockets, but there are WAY more to take into consideration when using sockets. You're basically going to have to create some form of server. You'll have to do handshaking on first connecting, then assign the speciffic app connecting to the server a new port number to connect on, so that other apps can use the first port for handshaking as well.

Then you'll have to implement threads to handle each instance's communication, a protocol for your apps to communicate...

If I were you, I'd rather implement the system using either servlets or jsp. It takes care of all of the above.
Manish Sridharan
Ranch Hand

Joined: Jul 19, 2005
Posts: 64
hi Scheepers de Bruin:
First i would like to give thanks to you for replying my query.
Even i was some how convinced that it would be possible to do it thru jsp and servlets. however the application is so small i really find it of no use to install apache for the same.. but ne way as u suggest it rite way would be to go thru the jsp and servlet way..

but i still have a doubt where should be socket programming is usefull. i think it is more or less redundant with coming of servlets and jsps...

i got another query :
if i want to use swinng applet in browser add it contains diffferent buttons which fire database querys like select update or insert.

Will it be okay in the scenario where more than one people is accessing the application..
b'cos in that case there are chances one user is updating the recordeset which is deleted by another user.
Scheepers de Bruin
Ranch Hand

Joined: Jul 19, 2005
Posts: 99
Not quite redundant - remember in a web-application, a web-page is simply a user interface - a way for the user to interact with the application.

The browser and the server actually still need some way to communicate.

If you use an applet, your're just running a mini-application in the browser, and you'll still need to program sockets et al.

Your database should be able to handle multiple connections without too much hastle.
Manish Sridharan
Ranch Hand

Joined: Jul 19, 2005
Posts: 64
Thanks Scheeper for ur kind reply ...
My yahoo id is gaurav_crab80@yahoo.co.in
Please be in touch ... ur opinion is quite valuable to me

Thanks

Gaurav
Scheepers de Bruin
Ranch Hand

Joined: Jul 19, 2005
Posts: 99
You are most welcome!
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
For a small application that doesn't need a web interface there are plenty of options better than writing your own socket code. When writing your own sockets there are all sorts of special cases to think about. Problems that have already been solved in Java for many years.
JMS Java Message Service is one example.
Bill
Manish Sridharan
Ranch Hand

Joined: Jul 19, 2005
Posts: 64
Thanks to everybody for their kind replies....
Can you explain me in brief about java message services. i follow all details from documentation...

Thanks

Gaurav
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
I tried to find a basic JMS tutorial using google but most were tied up with J2EE complications. This tutorial by the author of a JMS book looks like it is on the right track.

Basically, JMS works like this.
Somewhere on your network you run a JMS server - it handles two kinds of message transfer between clients. Publish-Subscribe and Point to Point.
Messages can be plain text such as XML or serialized Java objects.
In Publish-subscribe, one client publishes data in a JMS message to the server. The data is identified as belonging to a particular topic.
The server keeps a copy and sends copies to all clients which subscribe to that topic. The clients do not have to be connected when the data is published, they can connect any time and get the current topic contents.

In Point to Point, there is only one client getting messages on a specific topic.

So in your project (if I understand correctly) the process that updates the records would be getting point to point update messages that would be held by the JMS server until the process could get to them one at a time. Every time a modification is done, the new data gets published. Clients that need the updated information would subscribe to the topic where the updated data is published.
Bill
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Bill, even in "point to point" mode, I think if we set up many listeners on the same queue JMS will deliver the message to one of them chosen by some algorithm? We're counting on this in a clustered environment, but haven't actually deployed and tried it yet. BTW: We have IBM MQ-Series under teh covers.

Oh, and thanks for that link! It would seem I should spend some time reading up on this.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: client-server based Query