Re: Question about destructor of database and multiple use access

2016-07-29 Thread Suliman via Digitalmars-d-learn
So my last variant is right? How can I inspect code, to better understand how GC works? Also where I can find idiomatic code with comments? Just to read for better understand design solutions.

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Kagamin via Digitalmars-d-learn
On Thursday, 28 July 2016 at 15:24:22 UTC, Dechcaudron wrote: Also, I'm assuming what I said about calling destroy(instance) is as correct as calling a cleanup method? Class destructor also automatically calls destructors of struct members of the class.

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Lodovico Giaretta via Digitalmars-d-learn
On Thursday, 28 July 2016 at 15:24:22 UTC, Dechcaudron wrote: On Thursday, 28 July 2016 at 15:18:24 UTC, Lodovico Giaretta wrote: 3) at program end, live objects are not scheduled for finalization; 4) at program end, pending finalizations from previous collections may not be run. I didn't

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Lodovico Giaretta via Digitalmars-d-learn
On Thursday, 28 July 2016 at 15:02:58 UTC, Dechcaudron wrote: On Thursday, 28 July 2016 at 14:43:32 UTC, Lodovico Giaretta wrote: No! Never run important finalization in a class destructor! The GC is not obliged to run the destructors, so you may end up with your objects destroyed but the

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Dechcaudron via Digitalmars-d-learn
On Thursday, 28 July 2016 at 15:18:24 UTC, Lodovico Giaretta wrote: 3) at program end, live objects are not scheduled for finalization; 4) at program end, pending finalizations from previous collections may not be run. I didn't know these two, can I get source on them? Also, I'm assuming

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Dechcaudron via Digitalmars-d-learn
On Thursday, 28 July 2016 at 14:24:16 UTC, Suliman wrote: void dbInsert(string login, string uploading_date, string geometry_type, string data) { Statement stmt = conn.createStatement(); //stmt.executeUpdate("..."); // some processing of

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Dechcaudron via Digitalmars-d-learn
On Thursday, 28 July 2016 at 14:43:32 UTC, Lodovico Giaretta wrote: No! Never run important finalization in a class destructor! The GC is not obliged to run the destructors, so you may end up with your objects destroyed but the connections still open. For this kind of important things, you

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Lodovico Giaretta via Digitalmars-d-learn
On Thursday, 28 July 2016 at 14:33:26 UTC, Dechcaudron wrote: On Thursday, 28 July 2016 at 14:01:45 UTC, Suliman wrote: 2. Should I call destructor and how it's should like? You certainly want to close the connection to the db. Basically, the destructor is intended to free resources such as

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Dechcaudron via Digitalmars-d-learn
I don't know anything about the driver you are using, but from my general experience with DBs I'll try to give you some insight. On Thursday, 28 July 2016 at 14:01:45 UTC, Suliman wrote: 1. Should declaration of them be field of class? I'd say so. If you intend to use each instance of the

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Suliman via Digitalmars-d-learn
class GDB { Config config; MySQLDriver driver; DataSource ds; Connection conn; this(Config config) { this.config = config; driver = new MySQLDriver(); string[string] params; string url =