Hello everybody,
I am really new in the
Java world. Recently, a friend told me about this ranch and I love it. I like metamorphic illustrations
I have this application to develop, and I am trying not to re-invent-the-wheel here getting the best OO-approach possible. I have some ideas and read a number of books on the subject I am now 'almost' ready to proceed. Since I found out about the barn here
I though I will share my problems with you. Since this is my first real Java program I am about to write. Any suggestions or ideas are greatly appreciated.
Currently, I have a C program that accepts database connections as arguments from the command line. The program then reads a file (from stdin) that is structured consisting of header with SQL instructions, followed by data sections and reference points to each SQL statement.
The program is to load the data to all database connections specified on the command line, and to commit to each database only if all INSERTS succeeded for all database connections. If ANY database had a problem inserting the data, the program issues a ROLLBACK. Thus, we have our data replica properly in sync.
The problem with this program is speed. The entire database related work is done in a queued fasion. Each connection's work is done in a loop in a serialized way. Using threads and with out multi-processor machine, if we could set up that each database connection should do its work in its own
thread and have a kind of Boss/Worker relation:
The Boss will create n threads per specified connection on the command line. Then the Boss can supply the SQL instructions for each Worker, then supply the data, and the Boss should wait for all workers to get the data in the database in their own thread. When all workers are done, the Boss will inspect if there were no errors in any of the workers, and then instruct the workers to either commit or rollback.
Not Done Yet, Yes for now this will run from one machine but in reality these databases are on different machines, and I would really like to be able to use the resources from the host machine for each database. Therefore, when I design my class I want to keep in mind to eventually be able to do some cool stuff with RMI.
Thanks,