F Lucas

Greenhorn
+ Follow
since Jul 04, 2017
Cows and Likes
Cows
Total received
2
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
1
Total given
5
Given in last 30 days
2
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by F Lucas

Hello. I am trying to learn how to use DataSources, but I cannot understand the oracle tutorial because it does not use vendor specific datasources (such as connector/J, which im using.)  
I tried searching in many ways, but it keeps showing me how to connect via context.  
I need help understanding what to do after making an instance of it.
Here is the only part I succeeded in making without producing any errors.

....Not much.
I also took a look at the official documentation, and it tells me the url syntax but no ways of using it.
Any help would be appreciated.
Wow now I feel really stupid. It works. thank you for the answer.
3 weeks ago
Double checked both runtime and build configurations. Both has the driver JAR included.  
And here is the error code.:
java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at ems.Ems.main(Ems.java:36)
I hope this helps.
Thanks for your time.
3 weeks ago
Hello. I was going to practice jdbc, so I installed the microsoft jdbc driver.
But when I call Class.forName(driverName), it gives me the exception.
I am using eclipse IDE, so I know its not human error. I already configured the class path correctly, and I can see the referenced libraries mention the driver.
But it keeps giving the exception, and I can't proceed with anything because of it.
Big thanks to anyone who answers/tries to.
3 weeks ago
Hello, and sorry for the late reply.  
I was away from my pc for a lot of time.  
Anyways, here is the interfaces you asked for.  
Any criticism would be appreciated.
Getter:

Setter:


I made those interfaces, and plugged them into a single main method that uses an object that implements login, then made a switch statement that uses every interface.  
I first made the local text version to debug important parts, and after that I will make an MySql version of Getter and setter.  
Is this usage appropriate?
1 month ago
This is the version of the code that works.

When I encrypted and decrypted in a one-time operation (One doFinal and nothing else), It threw a bad tag exception everytime.
1 month ago

Campbell Ritchie wrote:That looks a very complicated way to look for numbers, particularly when you have been provided with a reliable and well‑tried technique.


I just wanted to give an answer that accepts any amount of inputs. OP did not specify how many numbers he wants to calculate.
1 month ago
You need to atleast tell us what you want to do. If you just post like that with no context people will think you are just lazy and not trying.
2 months ago
Want a quick answer?
When to use getters and setters? almost always.
When to use inheritance? Java lets you build programs from outside to the inside, instead from bottom
to the top. This helps maintaining and updating code easier. Inheritance is one of the ways java achieves that. For example....
Theres a class movableCharacter.
You can make a class npc that has his move() method replaced by an AI, and a class player
that uses the input scanner of his class to move.
Why is this important? Because you can say Object.move() and it wont matter if it is an npc object or a player object and it will still move with no errors.
2 months ago
I would do this to ensure fool-proof.  
Print "Please input numbers, and input "calculate" to calculate the average."
1. Get an input scanner.
2. Initialize a boolean "breakRequested" and "notDigit" as false
3. Initialize arrayList of ints
4. While breakRequested is false, if input.equals("calculate") is not true
5. for(char c :input.toCharArray()){
6. if c.isDigit()
7. Nothing
8. Else notDigit = true and break;
9. if notdigit is false
10. add input.parseInt to the arraylist
11. Else print "please input only numbers."
and if the input equals calculate is true you set breakRequested to true and break. It ends the loop.
Probably not the best answer. I did not actually write the code to see if it is practical, but I hope
it helps.

2 months ago
Thank you Stephan. After changing the methods and double checking everything, I noticed a few things.
And it now works!
I will leave everything I did to make it work here.
1. I was only saving the value from .doFinal() and that was wrong.
FIX: Use .update() first, save into an array, and concatenate the two arrays with arraycopy.
2. Apparently When using base64 and encryption together, encoding first is wrong.
FIX: Encrypt first, then encode. Then decode before decrypting.
3. No more inconsistencies on the input and output. But now it gave me a tag mismatch error.
FIX: I had to extract the authentication tag (16 bytes in the end of the ciphertext) and use .doFinal
with it as parameter to make it verify the tag.
I learned a lot from debugging this. Again, thank you for the tips.  
I hope you have a VERY nice day!
2 months ago
Thanks for the reply. Just one more thing. Does it mean I have to
Export all the formatting code to a separate method
Make the method symmetric, and make it accept a parameter to change between encryption mode and decryption mode
Polish the code more
And print out the Key, salt, and ciphertext in Base64 for debug purposes
Am I correct? I just wanted to make it sure before starting to work on it.
Thanks in advance.
Edit : I use excessive amounts of comments on my code because it helps me remember basic code. But it probably reduces readability, so I will omit it next time.
2 months ago