re: Icarus Server (Production) - [Python, Multi-DB/MySQL]
Quote:
Originally Posted by
scottstamp851
He's releasing objects after use, the GC handles disposal afterwards. This code is fine.
Sent from my iPhone using Tapatalk
Except there are still resources allocated in the libraries being used in the example which have to be manually free'd before the GC handles them.
I'm not telling bullshit, he's gonna figure it out eventually.
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]
Quote:
Originally Posted by
The General
Except there are still resources allocated in the libraries being used in the example which have to be manually free'd before the GC handles them.
I'm not telling bullshit, he's gonna figure it out eventually.
Ah yeah, the PreparedStatement instances need to be closed (as far as I can see?).
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]
Quote:
Originally Posted by
The General
Except there are still resources allocated in the libraries being used in the example which have to be manually free'd before the GC handles them.
I'm not telling bullshit, he's gonna figure it out eventually.
I've done my research.
Code:
public static void releaseObject(ResultSet row) {
try {
row.close();
} catch (Exception e) {
}
try {
row.getStatement().close();
} catch (Exception e) {
}
try {
row.getStatement().getConnection().close();
} catch (Exception e) {
}
}
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]
Quote:
Originally Posted by
Quackster
I've done my research.
Code:
public static void releaseObject(ResultSet row) {
try {
row.close();
} catch (Exception e) {
}
try {
row.getStatement().close();
} catch (Exception e) {
}
try {
row.getStatement().getConnection().close();
} catch (Exception e) {
}
}
Not surprised at all. I knew it was hidden in that function. :D:
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]
Quote:
Originally Posted by
Quackster
I've done my research.
Code:
public static void releaseObject(ResultSet row) {
try {
row.close();
} catch (Exception e) {
}
try {
row.getStatement().close();
} catch (Exception e) {
}
try {
row.getStatement().getConnection().close();
} catch (Exception e) {
}
}
Good, now you abuse the fact you cannot re-use the prepared statement which is exactly what it was ment for.
And what if an exception occurs, your connection would still stay open ;)
Cos if I do a select:
Code:
PreparedStatement stmt = whatever().prepare("SELECT * FROM users WHERE id = ?");
stmt.setInt(1, userIdOne);
ResultSet set = stmt.executeQuery();
if(set.next())
{
do something(set);
releaseObject(set);
}
set.setInt(1, userIdTwo);
stmt.executeQuery();
That won't work as you've already closed the connection in releaseObject.
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]
Quote:
Originally Posted by
Quackster
I've done my research.
Code:
public static void releaseObject(ResultSet row) {
try {
row.close();
} catch (Exception e) {
}
try {
row.getStatement().close();
} catch (Exception e) {
}
try {
row.getStatement().getConnection().close();
} catch (Exception e) {
}
}
Bro, don't let Wes get to you! You're doing fine :love:
Any updates? :):
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]
Quote:
Originally Posted by
The General
Good, now you abuse the fact you cannot re-use the prepared statement which is exactly what it was ment for.
And what if an exception occurs, your connection would still stay open ;)
Cos if I do a select:
Code:
PreparedStatement stmt = whatever().prepare("SELECT * FROM users WHERE id = ?");
stmt.setInt(1, userIdOne);
ResultSet set = stmt.executeQuery();
if(set.next())
{
do something(set);
releaseObject(set);
}
set.setInt(1, userIdTwo);
stmt.executeQuery();
That won't work as you've already closed the connection in releaseObject.
Well you see, the object is only closed at the end when it's not needed anymore. I can't grasp the fact that you'd think it would be any other way.
http://i.imgur.com/IKAIxBO.png
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]
Quote:
Originally Posted by
Quackster
Well you see, the object is only closed at the end when it's not needed anymore. I can't grasp the fact that you'd think it would be any other way.
Bro, he's foreign
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]
That was a rather secretive development, wb Alex.
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]
Quote:
Originally Posted by
Dominic
Bro, don't let Wes get to you! You're doing fine :love:
Any updates? :):
No updates at the moment, I'm out at university for the whole day, but when I'm home I'll get cracking on some features, for example there's no ability to edit room details/delete room/create room... lol
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]
lol @ three try-catch blocks in releaseObject
lol @ The General who pretends that he is capable of anything
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]
Quote:
Originally Posted by
TheOleg
lol @ three try-catch blocks in releaseObject
lol @ The General who pretends that he is capable of anything
It's a silent function. If it's all under one try-catch and an error throws - because there's a chance an error will throw, the rest of it won't be closed. I've done everything for a reason.
Lol @ your stupidity.
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]
This is amazing! goodluck!
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]
Quote:
Originally Posted by
Quackster
It's a silent function. If it's all under one try-catch and an error throws - because there's a chance an error will throw, the rest of it won't be closed. I've done everything for a reason.
Lol @ your stupidity.
exception handling - Java if vs. try/catch overhead - Stack Overflow
Java GC is bad so we should make our own! Even worse!
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]
Quote:
Originally Posted by
TheOleg
Like I said, I can't have it any other way.