General Insert statement to DB
i have a question.
i am working on a project, and i want it to have a package that holds all the GUI classes and a package to hold the DB classes.
i work with MySql and Eclipse.
i have a class "MySqlConnection" that have a method called "InsertToTable", i want this method to be general.
what i mean?
let's say for example i have this class in the GUI that have a button that when pressed it Inserts the fields the user filled into the DB.
for example the fields are: book_name,author_name.
i want that the button in the GUI will send a TreeMap that contains the data the user typed and it will send it to "InsertToTable" method. and the "InsertToTable" will actually insert the data it received with a Prepared Statement.
that's all good but, i want "InsertToTable" to be general, if now i work with another GUI that it job is to insert data to a table that has 5 columns i want this method to deal with 5 columns, and with any number of columns, so it would be as general as possible.
i know how to use Prepared Statements with question marks, but i don't know how to use the same Prepared Statement for different tables that will deal with different number of columns.
Thanks in advance :)