Win a copy of Microservices Testing (Live Project) this week in the Spring forum!

Liang Anmian

Ranch Hand
+ Follow
since Jun 25, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Liang Anmian

I don't quite understand what you meant. What I'm encountering now is that I need a way to close all remote database connections if I initiate a shutdown. Currently, it stops the connection factory, but doesn't stop existing connections.
I am now encountering a little issue here. My application architecture is very similar to almost anybody else's. I host a connection factory at the server. If a client wants to get a DB connection, they have to obtain the remote connection factory object and call createDBConnection(). This method will return an object of type DBConnection (a remote interface).

However, doesn't this approach mean that I will need some way of tracking all the DBConnection objects that are created? What if the admin wants to stop the server? This will only stop the connection factory, but NOT the DBConnection objects. Do I need to store a list of all the DBConnection objects created, and close them as well?
Let me see if I understand this correctly. You read the database file and print the magic cookie value to the console. Now that you know the valid magic cookie, you hardcode that value as a constant to check for (in)valid database files?

I didn't realize that this has to be done. I thought the magic cookie is there for the sake of being there. LOL!
I happened to stumble across this framework while studying for SCWCD. From the looks of it, this framework looks interesting. But I've got a question. If I use Struts, does this mean that my web application is only compatible with Tomcat?

I'm really sorry if this question is silly.
16 years ago
Oops. Apparently I didn't read your reply carefully. In other words, you still have to hardcode the index (according to what you mentioned). It's just that you consolidate all possible future changes to one class, without worrying that the GUI will break down?
Your method sounds great! Thank you for sharing! Will get on to work now!
Do you mean that your table model is a custom one? As in, you created a custom subclass of AbstractTableModel?
That means something like maybe: "Customer ID" for "owner" column. So I store these constants in a properties file, and use the "Customer ID" name to get the database column name.

If I do it this way, doesn't this mean that the database admin will have to update the properties file everytime he decides to make a change to the database (e.g. if he adds in a new column etc)? I guess if I mention this in the choices.txt it should be ok?

PS: Must these be stored in suncertify.properties? I can actually create another properties file and store it inside the JAR file itself (instead of current working directory), right? I guess this does not violate anything.
[ November 12, 2005: Message edited by: Liang Anmian ]
Hi there,

Currently serving army now, so my SCJD assignment progress is delayed. Anyway, I have a little issue here.

I got the Bodgitt & Scarper assignment. I'm implementing RMI, and one of the remote methods will allow me to retrieve the database schema (the column names). This will allow me to prevent hardcoding of column names into the client GUI model.

I have a "Book" button at the bottom of the GUI. I will like to implement a tiny effect, where this button will self-disable when the user selects a record which has already been booked. This will prevent them from attempting to book an unavailable record. The problem now is, in my listener code, I have to check the model and see if a customer ID exists for the selected row. If there is a customer ID, that means the record has been booked, and vice versa. It seems that the only way I can check is to hardcode the index of the customer ID column (in my case, 5).

Is this a good way to do things? I mean, I get the schema from the server, yet in my GUI, I assumed that the customer ID is index 5. This seemed contradictory, but I can't think of other ways to get this right. Any suggestions? Or am I in the wrong direction?

PS: Ok I just searched the forum for similar queries. It seemed that there is no way to prevent this. No matter what you do, you have only 2 choices:

i) Hardcode the column name, and search for the index using that name.
ii) Hardcode the index.

So do I conclude that there's no way to prevent hardcodings?
[ November 12, 2005: Message edited by: Liang Anmian ]
Hi, I created the following simple JSP for testing:



Before running the JSP, I intentionally disabled cookies in my Firefox browser. Now, when I get to the page, I mouse-over the link, and yes, I can see the session ID. Now I refresh the page (by using refresh, not by clicking on the link, by the way, the link simply links to itself), and the session ID changes! But, if I clicked the link instead of refreshing the window, the session ID remains constant.

What is happening?
[ July 30, 2005: Message edited by: Liang Anmian ]
One way is catch the IOException, and return an error value (e.g -1).
Sorry, but I'm still very confused over this issue. Let's imagine I get the schema from the server. Now, when you search, how do you form the String[] criteria? I'm sure it's either:

1) You hard code the column name, and search for the index of that column. From there you form the String[].

2) You hard code the index itself.
Unreferenced can only be used for your RMI solution if, and only if, your server issues some sort of DBConnection object to every client (meaning, unique to every client). Unreferenced takes over only when there are no more references to the remote object. Be noted, though, binding to the registry counts as 1 reference.

In my opinion, using timed locks is a little overkill. Unreferenced is much easier. But after all, like I said, it depends on how you design your application architecture.
Talking about hardcodings, what I've done is that I wrote a subinterface of DB, and one of the new methods is String[] getSchema(), which returns the field names.

However, I have not really decided what to do about the client side. I believe that in one way or another, I need to hard code something. Imagine the scenario where you have to search the database. For my B&S assignment, I have to search by location and name. So now, how do I form the String[] that constitutes the criteria? In order to do that, I must assume that 2 of the fields will be named as "name" and "location" respectively, because I do NOT assume that their positions will always be the same. What if, say, this db admin shifted the name field to another position (e.g now it becomes the second field instead of the first)?

What I intend now is get the schema from the server. Then, when performing the search or book, I search the JTable for the index of the respective fields. From there, I form the String[].

I wonder if this method can be justified?
So the bottom line is, there is definitely more than 1 way to design the MVC architecture. No right and wrong here. Ultimately, it depends on how your application works.