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 Developer Certification (SCJD/OCMJD) and the fly likes DBFileLocation and Server and StandAlone Modes of operation 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 » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "DBFileLocation and Server and StandAlone Modes of operation" Watch "DBFileLocation and Server and StandAlone Modes of operation" New topic
Author

DBFileLocation and Server and StandAlone Modes of operation

Murali Kurukunda
Ranch Hand

Joined: Oct 20, 2003
Posts: 36
In my Data class I am caching the records in memory with a singleton like implementation. The first request that tries to create the Data class will load cache into memory and al others use that cache.

And for the location of the database the first request to load the cache into memory will lookup the location in the suncertify.properties file and load it.

My question is would the examiner try to test the Server Mode and StandAlone modes of operations on the same machine with different locations for the database file. With my implementation only one db location is accepted.

Is it OK to assume that the location of database file would be same for both the Network client and Standalone modes of operation? If at all I lose points for this, how big is the risk?

The other option is to use different property names for the dbFileLocation like
Server B_FILE_LOCATION and StandAlone_DB_FILE_LOCATION. This implies that I pass a parameter to my Data class implementation to specify the mode of opearation. I do not like this idea very much.

Let me know your thoughts on this.
Murali
Daniel Simpson
Ranch Hand

Joined: Sep 02, 2004
Posts: 181
Originally posted by Murali Kurukunda:
In my Data class I am caching the records in memory with a singleton like implementation. The first request that tries to create the Data class will load cache into memory and al others use that cache.

And for the location of the database the first request to load the cache into memory will lookup the location in the suncertify.properties file and load it.

My question is would the examiner try to test the Server Mode and StandAlone modes of operations on the same machine with different locations for the database file. With my implementation only one db location is accepted.

Is it OK to assume that the location of database file would be same for both the Network client and Standalone modes of operation? If at all I lose points for this, how big is the risk?

The other option is to use different property names for the dbFileLocation like
Server B_FILE_LOCATION and StandAlone_DB_FILE_LOCATION. This implies that I pass a parameter to my Data class implementation to specify the mode of opearation. I do not like this idea very much.

Let me know your thoughts on this.
Murali


I did the last option (the one you dislike ) Here's why:
All configuration must be done via a GUI, and must be persistent between runs of the program. Such configuration information must be stored in a file called suncertify.properties which must be located in the current working directory.

Here is what will happen when you try to do your solution: The assessor runs local, configures datafile location, runs and exits. The assessor does the same thing for the server. Here's the error: The assessor decides to run local again and ooops! You have to reconfigure the settings because the server overwrote them. That means your configurations are not persistant between runs of the program and you would probably fail. All configuration needs to be stored in that suncertify.properties and you need to make different keys such as Server_DataFileLocation or Local_DataFileLocation, or any kind of keys like that. I had my Data take a parameter determining either local or network. Depending on that, it knows which location to search for the datafile. Lastly, you said:

My question is would the examiner try to test the Server Mode and StandAlone modes of operations on the same machine with different locations for the database file. With my implementation only one db location is accepted.

Is it OK to assume that the location of database file would be same for both the Network client and Standalone modes of operation? If at all I lose points for this, how big is the risk?

You can't assume such things. Code to make it possible to have the server and standalone configure for two file locations. Also, the network client has no concern about the database file location. Only the server or standalone should be concerned about the location and configuring it. Hope all of this helps!


SCJP 1.4<br />SCJD 1.4
Murali Kurukunda
Ranch Hand

Joined: Oct 20, 2003
Posts: 36
Thanks for the reply . I agree with you. I did not like the option of using separate keys for SERVER B_LOCATION and STANDALONE_DB_LOCATION, because I did not want to pass the location around. But I realised I could just add a setter for the dbFileLocation in my data class set it whenever I read the property.

So here is what I did:

public static void setDBFileLocation(String dbFileLocation)

in server mode:

//try to read SERVER_DB_LOCATION from properties file
//if the property does not exists propmt the user for file location
//then call the static setDBFileLocation() on Data

//same thing in Stand Alone mode with STANDALONE B_LOCATION

please comment!
Murali
Daniel Simpson
Ranch Hand

Joined: Sep 02, 2004
Posts: 181
I did mine a bit different. When a user launches the app, if the properties file doesn't exist or a specific key-value in the properties file doesn't exist, it will make the user configure settings, else they can use existing settings.

The code in my Data class is like this:

My Data takes an int param determining whether its local or network.

Hope this gets you started!
[ January 14, 2005: Message edited by: Daniel Simpson ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DBFileLocation and Server and StandAlone Modes of operation
 
Similar Threads
URLyBird GUI start up how to get all Rooms?
Simple question about Data Access Component
NX: Core distributed computing concept and locking
Should server configuration be provided by suncertify.properties ?
Database location and properties file doubts.