multiple commits

yo

in the current program i'm working on i need to insert multibale new records in a database

at the moment i'm thinking of making 1 connection object & passing this along everywhere in the database

(this to make it a litlle more centralized)

now i noticed that if i dont close the connection after all the comits the data doesn't appear in the database

what i want to know if its possible to commit data to a database without closing the connection

[493 byte] By [Resendera] at [2007-10-2 17:38:23]
# 1

That's certainly not the way it works in most databases; it may be something to do with your particular database or driver. Or maybe you're doing something wrong in your code, although I can't think what that might be. Or maybe there's something wrong about the way you check to see if the records are there... I guess we need more details.

StuDerbya at 2007-7-13 18:55:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
The only database [which is not truly a database] which shows such a behaviour is MS Access. It requires that the connections should be closed for the updates to reflect correctly.
aniseeda at 2007-7-13 18:55:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
it indeed MS Accessso you're saying the changes ill be implemented but they wont show up untill .close is done
Resendera at 2007-7-13 18:55:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

> it indeed MS Access

> so you're saying the changes ill be implemented but

> they wont show up untill .close is done

Yes, and that's a specific problem I encountered only with Access. But as a good practice, you should always close your database connections when the job is done.

In your specific case, you could try using a "real" database... the one which behaves well. http://db.apache.org/derby/ is one. :)

aniseeda at 2007-7-13 18:55:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5

> Yes, and that's a specific problem I encountered only

> with Access. But as a good practice, you should

> always close your database connections when the job

> is done.

>

> In your specific case, you could try using a "real"

> database... the one which behaves well.

> http://db.apache.org/derby/ is one. :)

& hence lies my problem i'm not allowed to use another database then access

then i just need to be sure i connection.close is called by all possibale ways the program exits

Resendera at 2007-7-13 18:55:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6

> & hence lies my problem i'm not allowed to use

> another database then access

> then i just need to be sure i connection.close is

> called by all possibale ways the program exits

Ahhhhhhhhhh!

Why is this a problem? It darn well shouldn't be. You should already be closing ALL your JDBC resources properly before your program exits.

Resendera at 2007-7-13 18:55:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...