I have an program that is using a prepared statement to connect and write to a database working nicely, and now need to create a middle-man program to insert between this program and the database. This middle-man program will actually write to multiple databases and handle any errors and connection issues.I would like advice as to how to replicate the prepared statements such as to create minimal impact to the existing program, however I am not sure where to start. I have thought about creating a SQL statement class that mimics the prepared statement, only that seems silly.The existing program is in Java, although it's going to be networked anyways so I would be open to writing it in just about anything that would make sense. The databases are currently MySQL, although I would like to be open to changing the database type in the future. My main question is what should the interface for this program look like, and does doing this even make sense?A distributed DB would be the ideal solution, but they seem overly complex and expensive for my needs. I am hoping to replicate the main functionality of a distributed DB via this middle-man. I am not too familiar with sql-based servers distributing data (or database in general...) - perhaps I am fighting an uphill battle by trying to solve it via programming, but I would like to make an attempt at least.
Prepared statement alternatives for this middle-man program?
java;database;interfaces
Ideally, the interface for your program-in-the-middle would look as similar as possible to your existing program's interface to the database. You might want to start by building a layer in your existing program that interacts with the database, and all other components in your program interact with the database by calling the functions in this new layer. Then you can start separating this layer into a separate library.If necessary, build a new program around this library that can be called by a web service, or some other messaging method. You could also build a separate layer in the old program that matches the old interface that your original program calls, and this new code will call any new service/messaging system to connect to the new program-in-the-middle.The program-in-the-middle can use prepared statements or anything else. It shouldn't matter to the original program how the new middle-program interacts with the database, as long as it works.