Mark Oneill

+ Follow
since Feb 08, 2018
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mark Oneill

Hmm, I've tried adding the line e.printStackTrace(); into my exception handling, and the IDE (NetBeans 8.2) gives me the message "Throwable.printStackTrace() should be removed" ?
11 months ago
Thanks for the advice Paul - I will amend my exceptions with that! :-)
11 months ago

Am I right to believe that the rs.close() statement before the return statement is redundant? As the finally block is always executed and therefore rs.close() is called twice depending on the result set?
11 months ago

Dave Tolls wrote:You could cut down the number of db accesses there.
Just get the PlayerUID for the given AreaID.
If it matches then exit, if not then do the Friends query.
That middle SELECT is a bit unnecessary.
Indeed, you might be able to come up with a single query, but not knowing the logic I can't say.

In addition I would recommend reading up on PreparedStatements.
Seeing concatenated queries like that makes me itchy.

Oh yes, and your ResultSet should be closed off in a finally block (or use a try-with-resources).
At the moment, if you get an exception inside there you may end up leaking resources as the ResultSet(s) won't be closed.

Thank you for your post Dave. This is my first "real world" attempt at writing any Java / SQL commands since my Uni days (almost 10 years ago now). Indeed I can now see that the middle query is completely redundant! And as there are 30 odd of these events listeners, and potentially dozens of people calling them on a regular basis the removal of that query alone will make a lot of difference! I thank you again for pointing this out! :-)

Also, I had not heard about Prepared Statements - looks really useful. I will en-devour to upgrade my code to use these!  

11 months ago
Hi guys! Thought I would share how I fixed this (in case anyone else stumbles upon this looking for an answer to their same problem).

It turns out that by using the same ResultSet object (in my case rs) for multiple queries caused these kind of errors.

Each query needs its OWN ResultSet object.

I now use use the approach 1st result set is rs, second is rs2, third rs3 etc.

Since doing this I've not had any problems!

11 months ago
Greetings everyone!

Over the past few weeks I've been writing a plugin for a game. The developers have released a API with event calls that you can build on. My plugin was going fine and on my test server it works as expected. But, when I upload the plugin onto my server which hosts the game after 10-15 minutes I get a crash (due to I expect more people calling these events).

The first crash caused:

So I though it was because I had not wrapped my SQLite commands with try catch statements. So I did this, and after some time on the server, with more people joining and doing stuff (causing these events to be called) I got another crash but this time it was (with my newly wrapped SQL statements:

Here is an example of one of my event methods with the SQLite statement in:

Can anyone see what I'm doing wrong here?
11 months ago
Thank you very much for your help Dave Tolls I will add a bunch of System.out.println() calls and see if I can see whats going on and where it's breaking!

Have a fantastic weekend!
1 year ago
Doubles and Integers are fundamental data types you cant just interchange between the two, as you will loose data!

But you can cast them if you are happy with loosing precision.


double d = 1.2;

int i = (Integer) d;

1 year ago

Dave Tolls wrote:Sorry, it's me being a bit dim.
The deserialisation skips normal object creation, so that instantiation of the List doesn't happen.

Ahh I did not know that! Thank you so much for spreading the knowledge

So if I create a method something like:

And then call this method in the "blank" constructor

That should stop my NullPointerExceptions?
1 year ago
Apologies for my dumbness I haven't coded in almost 10 years!
1 year ago

I thought I had initialised the ArrayList? :/
1 year ago
Thanks for the replies guys - a great community here. And I am glad to see the site is still up and running - I used to visit here often in Java 1.2 days ;) and have recently started to get back into programming. . .

I am saving each players data to an individual player binary file using

I'm then reading in the file again at a later date using

Within the Player class (version 2) I have a ArrayList with a method addToChatLog(String input) {array_list.add(input;}

It was when I called this method from a version 1 Player that I got the NullPointerException.

I suspect I may be doing something fundamentally wrong :/

1 year ago
The methods shown were just to illustrate. So it's not about optional attributes. The Player class is work in progress and things will be added to it over a period of time. Version 1, Version 2, Version 3, etc. With each new version new getter and setter methods will be added.

I was thinking about setting the serialVersionUID for each version to something different so I could identify if the object was an "old" one or not.

I suppose I will have to load the old object, check the serialVersionUID, pull out the getter methods return values, store them in temporary attributes and then reload them into a new object.

I was just hoping there was an easier/simpler way to do it than this.
1 year ago