Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

Martin Vanyavchich

Ranch Hand
+ Follow
since Sep 16, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
4
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Martin Vanyavchich

Today I've successfully passed OCPJWSD with 81%. I would have never succeeded without Mikalai Zaikins study notes and questions. Thank you Mikalai!
6 years ago
Hi,

did anyone try EPRactize Lab for Web Services certification? Did it help, was the material given sufficient to pass the exam?

Thank you for responses,
Martin
Hi Dmitry,

that's the catch, Java programming Language is a required prerequisite for UML course. Check the page link I posted and look for Required Prerequisites section. Personally I don't mind (too much) taking a class, but taking an entry class seems unecessary =/

Regards,
Martin
Hi,

VLC is country independent. But keep in mind, that you can't just take any class. Prerequisite for Object-Oriented Analysis and Design Using UML (OO-226) is Java Programming Language, Java SE 6 (SL-275-SE6), wich is realy basic stuff. Classes are like certifications, you have to start at the bottom.

Ragards,
Martin

I sent my assignment 29 Nov, and I also took the essay that day. On the pearson VUE account my status became PASS this monday (1 week), but I recieved no email from Oracle and nothing changed in Oracle certview page. Maybe there's only a problem with their notification systems. Did any of you check Pearson VUE history page?
Oh, and I had to do the course requirement (I took the LVC version), hope this isn't a factor.

Regards,
Martin
Hey,

Roel De Nijs wrote:
If you are always booking record number 0 (comment line 62), you wouldn't see 35 'booked no room' messages, because one client should have booked room 0, all other threads shouldn't be able to book the room.


I start my record numbers with 1 and not 0 so I got an instant RecordNotFoundException, fixed my code to solve that problem.

Roel De Nijs wrote:
So your original output is not what you should expect. And your "fix" is also questionable: changing it into a class variable which will be modified by a bunch of threads (in a non thread-safe way). I don't see how this could fix your initial problem.


You're right my fix is realy bad. Should probably use an Integer and synchronize on it. I thought that we're trying to start 35 threads, that will try to book rooms 1 trough 35, and some will fail at it. That's why I made it into a class variable.

Roel De Nijs wrote:

Martin Vanyavchich wrote:Now the record number gets incremented, and rooms 0 trough 35 get booked.


That's also weird. I don't think your database file contains 35 records at the start.


You're right again, I got five record not found Exceptions.

I was hoping to submitt my assignment today and my face changed six different colors when the test failed . Now I've fixed all the problems in my code. Roel thank you for the test class, you really saved me, I owe you one
Hi,

I've used the class provided by Roel to test my services and I've got 35 'booked no room' messages. After a good look at the code I've realized that we're always booking room with record number 0. So I deleted the int recNo = 0; in the run() method and I've just put private static int recNo = 0; at the top of the class, just under DB_PATH. Now the record number gets incremented, and rooms 0 trough 35 get booked.

Hope this didn't compromised the test in any way.
Hey guys,

I have some questions about codeing for the asignment.

1.) Do you think al lot of boilerplate code affects the score, since it could be interpreted as unecessary nesting depth increasement?
2.) All this Exception handling seems to be poluting methods and constructors signatures. For example, the constructor for my hotel room DTO:


Since there is a lot of parsing from strings a lot can go wrong. Are all those exceptions an overkill?

Any help will be appreciated
You have some logical mistakes in your SQL statements



I think you should substitute OR with AND to get the desired effect or even remove the lines with wildcards alltogether.



You can do the same for your other problematic statement.



There is no need to list all parameters, just the ones you need to narrow the results:



This will return just one entry, the first one you added to the table with patient_id 1. If you were to alter the statement and use OR in such a way:


Two entries would be returned.
(1,1,'Test','Hello','test@test.com',5); and
(2,1,'Testing','Hello','test@test.com',4)

the first one matches the firstName equality and the second one the lastName equality.


As for your PreparedStatement error, you have to be careful of the types that you're setting to replace your placeholders. Title, and nationality are numbers, and you should be using setInt() method. I think it should look something like this:


Be careful counting the '?' and what values you assign.


Hope this helped you.


Martin

fred rosenberger wrote:Concatenate your input string with a string 35 of your 'special characters'
return a substring of that, from 0-34



Brilliant!
6 years ago
Instead of using String you could use StringBuilder and append() method. That's a bit more eficient.

Instead of using a loop and appending one char at the end, you could use 'coin method'. Having static final strings of length 20, 10, 5, 2 and 1 characters each. Append those strings, depending on the space you need to fill. You would probably still use a loop, it would just take less cycles.
6 years ago
Just as Prem Pillai said, reverse the string and then match.

7 years ago
In this case String is used as generic type that this class will be holding when properly instantiated. Usually you would just use T or E. To fix compile time errors, you have two options. Specify when you're using Javas String or the type of class you'll be holding (holding is used very loosely here). As in this makeover.



Note java.lang.String usage, where we expect a Java String.

Preferably you chose another type holder such as forementioned T or E:


I hope this helped.