• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NX: Question about database location.

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello again,
In my URLyBird project, it says:

Your choice of RMI or serialized objects will not affect your grade, but no other approach is acceptable. In either case, the program must allow the user to specify the location of the database, and it must also accept an indication that a local database is to be used, in which case, the networking must be bypassed entirely."


How shall the program accept this indication? I am thinking of using a check button but I don't understand why we need this indication. Does this mean a remote database could be used?
If I am getting correctly:
* Network mode -> User aspecifies the location of the database.
* Local mode -> The program accepts an indication that a local database is going to be used and then the user aspecifies the location of the database.
If this is right, what is the point of doing this and what makes the difference between the network mode and the local mode? If a network client specifies the location of the database, where could that location be? On the server side or on the client side?
Can anybody give me a clue?
Thank you in advance!
Sang-Wook
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To my under standing,
Network mode: you need to ask user to input hostname and port number
Local mode: you need to ask user to input the path of the file.
You can design different GUI for netwok mode and local mode.
 
Sang-Wook Kim
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Yi,
Thanks for your reply. I think I got it now. As you said,
the location of the database in network mode refers to the
hostname and the port number whereas in local mode, the
location of the database is just the path of the db file.
But there is still one thing I dont get.
"it must also accept an indication that a local database
is to be used, in which case, the networking must be
bypassed entirely."
This applies to the local mode, right? But since I use
different command when running in different modes:
Network mode: java -jar runme.jar
Local mode: java -jar runme.jar alone
I think this is already an indication. It doesn't make much
sense running the application in local mode and asking
the user if he wants to run a local database.
Am I getting wrong? Guess so... -_-+
Sang-Wook
 
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Yi Zou:
To my under standing,
Network mode: you need to ask user to input hostname and port number
Local mode: you need to ask user to input the path of the file.
You can design different GUI for netwok mode and local mode.


Here I've got a doubt. When in network mode, how the servers know about the database? Where is the database location in network mode?
I think this should be a piece of information that should be considered by the client when communicating with the network server:
1) The clients needs to know IP address and port number of the server
2) The server must know where to read/write/update data
Marco
 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sang-Wook Kim:
Hi Yi,
But there is still one thing I dont get.
"it must also accept an indication that a local database
is to be used, in which case, the networking must be
bypassed entirely."
This applies to the local mode, right? But since I use
different command when running in different modes:
Network mode: java -jar runme.jar
Local mode: java -jar runme.jar alone
I think this is already an indication. It doesn't make much
sense running the application in local mode and asking
the user if he wants to run a local database.
Am I getting wrong? Guess so... -_-+
Sang-Wook


This is already an indication, if you provided in your application different configuratino behaviours depending on the type. If when running with your application will be able to know where the database is and to work with a local server rather than with a RMI one, then it's fine. Why not to use a modal Dialog box at the beginning with buttons for "Local" or "Remote" ? In case of Local, three text fields could be used for the user to specify the connection infos:
1) One text field for IP address
2) One text field for port number
3) One text field for db path
Marco
 
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
There are three operating modes (standalone, server, and network client) and an instance of the application can run in only one of them at any one time. The user specifies the operating mode for the application at the command line:
java -jar runme.jar alone ==> starts the application in standalone mode
java -jar runme.jar server ==> starts the application in server mode
java -jar runme.jar ==> starts the application in network client mode
The application needs to be configurable. The configuration items that are needed depend on the operating mode:
standalone mode ==> database file location
server mode ==> database file location
network client mode ==> database server host
 
Sang-Wook Kim
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to Macro and George for the replies.
As George wrote,


java -jar runme.jar alone ==> starts the application in standalone mode
java -jar runme.jar server ==> starts the application in server mode
java -jar runme.jar ==> starts the application in network client mode


this is how the server and clients should run according to the
requirements and I agree to what George wrote:


standalone mode ==> database file location
server mode ==> database file location
network client mode ==> database server host


But still I don't get about this part:

it must also accept an indication that a local database
is to be used, in which case, the networking must be
bypassed entirely."

Can the argument "alone" of the command "java -jar runme.jar alone"
be an indication that a local database is to be used? Or do I
have to indicate it in another way?
Sang-Wook
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sang-Wook,

Originally posted by Sang-Wook Kim:
Can the argument "alone" of the command "java -jar runme.jar alone"
be an indication that a local database is to be used? Or do I
have to indicate it in another way?


The "alone" argument of the command "java -jar runme.jar alone" is the only indication that a local database is to be used. There's no other way to indicate that a local database is to be used.
 
Sang-Wook Kim
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks George,
Now it is clear! Thanks to all who replied!
Cheers,
Sang-Wook
 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
I am still a bit puzzled about these modes. I assume that the database is on the server computer. If the client has access to the server, then he will start the application in �alone� mode and specify the database location.
If the client is on another machine, he will access the application as a network client and will need an ip address and port number. He will not be able to specify the path to the database, since he has no access to the server file system.
But what is server mode for and when would it be used?
I assume that the server mode is only used in conjunction with the network client. Someone has to set up the port number and file location on the server side before the network client can access the server. Have I a correct understanding?
regards,
Simon
 
Sang-Wook Kim
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Simon,

I am still a bit puzzled about these modes. I assume that the database is on the server computer. If the client has access to the server, then he will start the application in �alone� mode and specify the database location.


Yes!


If the client is on another machine, he will access the application as a network client and will need an ip address and port number. He will not be able to specify the path to the database, since he has no access to the server file system.


Yes! Basically this was my first question. In the beginning I
understood the location of the database file refers to the path
both in local mode and remote mode. Thanks to the people who
replied, not I know that:
Location of the db file in local mode refers to the PATH!
Location of the db file in remote mode refers to the IP ADRESS & PORT!


But what is server mode for and when would it be used?


Server mode is for running the server program. As you said, server mode is used with the network client. Here is my scenario for this:
<network mode>
1. java -jar runme.jar server
==> A small window prompts up and asks the user for the path of
the database. (I am thinking of adding the port number here, because
it woule be more flexilbe that just hardcoding in the codes. And I
don't think the program needs ask ip address since most probably the
machine on which this command is typed would be the server -> I guess
for RMI, it could! be another ip address, which means the rmiregistry
server is running on a different machine and I want to register my
object there. But in our case, we have to consider the database, so
it's not the case. Am I right?)
2. After inputting the db file path & port number, the program starts
running the server and waits for the network client.
3. Not the network client types:
java -jar runme.jar
==> A small window prompts up asking for the location of the database,
which is the ip address and the port number. (I think the work "server"
instead of "database" makes it clearer.)
4. When running the GUI client program after input these properties,
these properties(ip address & port number of the database(server))
has to be stored in a file called "suncertify.properties " in the
current working directory.
<local mode>
1. java -jar runme.jar alone
==> ==> A small window prompts up asking for the location of the database,
which is the path of the local database file.
Here there is one thing I am not sure. What properties has to be stored
in the properties file? I read in a thread that it should include the
ip address & port number. Is that enough or shall I also add the location
of the database?
Please Correct me if I got anything wrong.
Good luck & Cheers,
Sang-Wook
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Simon,

Originally posted by Simon Ingram:
I assume that the server mode is only used in conjunction with the network client. Someone has to set up the port number and file location on the server side before the network client can access the server. Have I a correct understanding?


Yes.
Standalone mode has no particular relationship with the other two operating modes -- it really does stand alone.
An application running in network client mode is dependent upon another instance of the application running in server mode. Because of this dependency it makes sense to start the server before starting the network client. These two applications can be on different computers or on the same computer. Whoever starts the application running in server mode needs to know the location of the database file. Whoever starts the application running in network client mode needs to know the host name of the database server.
 
Simon Ingram
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi George,
Thanks for your post. You explained it very clearly, so thanks a lot.
Hi Sang Wook,
Yes, in my opinion your senario is OK. On the server you don't need to worry about the ip address. As for your other question, you will need to keep the ip address, port number and db path on the suncertify.properties file, but you use them as follows:
server: port, path
alone: path
client: ip, port
I hope we are all clear now!
best regards
Simon
 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, may I say that:
standalone mode:
My question here is: how is the reading/updating/writing of the database performed in this mode? By means of streams?
Network mode:
I assume that our examiner, will have started our application somewhere else in server mode and would like to know if our application can "talk" with the server in network mode. Now, because following what George said, the server MUST KNOW about the db location (in fact it will be the server which will act as interface between the client and the db), all the application will need to know in this mode is the IP address and port number of the listening server. If no server is listening, an exception must be returned to the client.
Server mode:
A network server (Socket or RMI) must be started (I would add listening on a port specified by the user) listening for connection. The server(s) must be written so that it knows about the db location. Here I think that the db location could be specified by the client (via a GUI or a property) when the application is started in server mode.
A major difference I would discuss here it would be between the server-network mode and the standalone. While the latter will make use of streams to write/read data from the db, I guess that the formers will also implement some serialization to move data across the wire between the client and the server. Am I right?
Marco
[ March 07, 2004: Message edited by: Marco Tedone ]
[ March 07, 2004: Message edited by: Marco Tedone ]
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marco,

Originally posted by Marco Tedone:
My question here is: how is the reading/updating/writing of the database performed in this mode? By means of streams?

Yes.

A major difference I would discuss here it would be between the server-network mode and the standalone. While the latter will make use of streams to write/read data from the db, I guess that the formers will also implement some serialization to move data across the wire between the client and the server. Am I right?

Yes.

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think you need to make the path to the database file configurable. The requirement says "[whether you use RMI or serialized objects,] the program must allow the user to specify the location of the database", and it does so under Server --> Network Approaches. So by "the database" I think they mean "the database server".
If you accept that they are really talking about the database server, then the location would just be
  • the host and port if the program is running as a network client
  • the port if the program is running as server
  • nothing in standalone mode, since there is no server


  • Of course, I would feel a lot safer about my assumption if I knew someone had tried it out and passed.
     
    George Marinkovich
    Ranch Hand
    Posts: 619
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Nicky,

    Originally posted by Nicky Bodentien:
    I don't think you need to make the path to the database file configurable. The requirement says "[whether you use RMI or serialized objects,] the program must allow the user to specify the location of the database", and it does so under Server --> Network Approaches. So by "the database" I think they mean "the database server".
    If you accept that they are really talking about the database server, then the location would just be

  • the host and port if the program is running as a network client
  • the port if the program is running as server
  • nothing in standalone mode, since there is no server


  • Of course, I would feel a lot safer about my assumption if I knew someone had tried it out and passed.


    The port isn't mentioned anywhere in the assignment instructions so you could elminate that as a configuration item too. Then your only configuration item left is a host name for the database server when running as a network client.
    I think it's always a dangerous game to take a requirement and add a qualifier that's not present in the specification. The result is that you weaken the requirement. I think that's what you're doing when you assume that they mean "the location of the database server" when they say "the location of the database". The addition of the word "server" restricts the meaning of the phrase "location of the database" in such a way that the requirement only applies to the database when it's being accessed by means of the database server, not when the database is being accessed directly as a file.
    Since the word "server" is not actually present, I think it's reasonable to assume that the phrase "location of the database" refers to database in its most general sense. Depending on the operating mode the term database can refer to the database file or the database server. For example, in the context of standalone or server mode the term database (in its general sense) refers to the database file. In the context of the network client mode the term database (in its general sense) refers to the database server.
    For the sake of argument let's assume your interpretation is correct and that you don't need to make the path to the database file configurable. This implies, of course, that you will have to hard-code the location of the database file (perhaps even the name of the database file if you don't think it needs to be configurable). I don't know that the examiner is under any obligation to test your application with the Sun-provided database file. What if he wants to test your application with say the \project\b_and_s\version_2.2.3\test_db.db database file. I guess the examiner could move his test_db file into the directory you hard-coded and he could even rename his test_db file to be whatever name you hard-coded for the database file in your application. Somehow I don't think this is going to make the examiner very happy.
    But how can you possibly know that the examiner intends to do something like this? Well if I wanted to be able to do testing like this I might put a requirement into the assignment instructions something like: "the program must allow the user to specify the location of the database." Could it be worded better (less ambiguously)? Absolutely, but you could make that argument about a number of requirements in the assignment instructions and indeed you could make that argument about any specification I have ever seen. English, or any natural language for that matter, is an imprecise tool at best. So you would have a decent chance to argue your case and appeal any unfavorable grade you may receive. But I think a good lawyer would rather win his case at trial rather then on appeal. An even better lawyer would like to settle his case on favorable terms before he even gets to trial.
     
    Mogens Nidding
    Ranch Hand
    Posts: 77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    George, thanks for your input. You arguments are very good, and I may just choose to put that pathname in the configuration just to get over it - it's not *that* hard. But then again, there are plenty of other spots where the requirements are bent - isn't this just another one?
    Let me give you some examples:
    When the specification says
    // Reads a record from the file.
    we interpret it is as
    // Reads a record from the file or return a previously cached value.
    When the specification says
    give up the CPU, consuming no CPU cycles,
    we interpret it is as
    wait using monitors (as opposed to busy waiting).
    So when it says
    the location of the database
    in the Network Approaches section, why should it not
    be as much subject to interpretation as the other statements?
     
    alzamabar
    Ranch Hand
    Posts: 379
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by George Marinkovich:

    But how can you possibly know that the examiner intends to do something like this? Well if I wanted to be able to do testing like this I might put a requirement into the assignment instructions something like: "the program must allow the user to specify the location of the database." Could it be worded better (less ambiguously)? Absolutely, but you could make that argument about a number of requirements in the assignment instructions and indeed you could make that argument about any specification I have ever seen. English, or any natural language for that matter, is an imprecise tool at best. So you would have a decent chance to argue your case and appeal any unfavorable grade you may receive. But I think a good lawyer would rather win his case at trial rather then on appeal. An even better lawyer would like to settle his case on favorable terms before he even gets to trial.


    As general approach, due to the fact that the exam requirements are subject to interpretation, the important thing here is to document why you took some decisions (this it what you would do also with a customer, wouldn't you?).
    As regards the db location, although you may argue in a discussion about your interpretation, I would always favour a flexible approach, so in this case I would let the user free to choose the db location.
    Marco
     
    Mogens Nidding
    Ranch Hand
    Posts: 77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    OK, you guys convinced me - I'll subject the pathname to configuration . Thanks!
     
    George Marinkovich
    Ranch Hand
    Posts: 619
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Nick,
    You're right everything in the assignment instructions is subject to interpretation (and unfortunately misinterpretation). Of course, some interpretations are better than others, but in some cases it seems that it is difficult to choose among different interpretations. In these cases, it can be helpful to look at the consequences of your interpretation, to think about how you might have written the specification, and to use common sense (that is, a combination of logic and experience) to pick the interpretation that you believe was intended by the author. The good thing about this assignment is that unlike in real life you don't really have to convince anyone else that you're right, it's sufficient to convince yourself.

    Originally posted by Nicky Bodentien:
    // Reads a record from the file.
    we interpret it is as
    // Reads a record from the file or return a previously cached value.
    Here the potential danger of our interpretation is that the record we return from the cache may be stale when compared to the record in the file. If we code to make sure that doesn't happen then does the user really care if the record came from the file, or if the record came from the cache which got it from the file. Are there circumstances in which the user is going to get different results? If not, then perhaps our interpretation is safe.

    When the specification says
    give up the CPU, consuming no CPU cycles,
    we interpret it is as
    wait using monitors (as opposed to busy waiting).

    Here the requirement seems to be concerned with not wasting CPU cycles so it seems like an easy choice to use a wait monitor rather than to use busy waiting since the first wastes fewer CPU cycles than the second.

    So when it says
    the location of the database
    in the Network Approaches section, why should it not
    be as much subject to interpretation as the other statements?

    Here I think there are negative consequences to interpreting this requirement to mean the user only wants to configure the database file in network client modes. That would mean that the user only wanted to be able to configure the database in network client mode, in all the other modes (standalone and server) he is content not to be able to configure the database file. That's certainly a possible interpretation of this requirement. So if you don't make the database file configurable in all modes and it turns out the user wanted to configure it in standalone or server mode then the user will probably think you failed to implement his requirement correctly.
    On the other hand, if you make the database configurable in all three modes, but it turns out the user only really wanted it to be configurable in network client mode, then the client might be surprised at your interpretation of his clear requirement, but he's not going to be prevented from doing anything he wanted to do. In other words, the consequences of guessing wrong in this case is that you did extra work you didn't have to do (making the database configurable in server and standalone modes). The user is not really affected adversely by your incorrect interpretation.

     
    reply
      Bookmark Topic Watch Topic
    • New Topic