1

I've a table Categories which has Skins and which has Images

Categories : id, Name
Skin :  id, name
CategorySkins : CategoryID, SkinID
Images : id, name
SkinImages: Skinid, ImageID

my question is to save a single Category instance with a few Skins and those Skins with a few Images. I've tried to build insert string dynamically, but I don't like this approach.

P.S. Is it possible to pass data like this: Catogory with list of skins and with list of images. as list to mysql procedure? Or simple is it possible to pass array as a parameter to procedure? Any suggestions about other way of solving this problem?

2
  • I want to insert this data together and I don't know how to pass it to mysql procedure. Commented Dec 5, 2012 at 20:49
  • 2
    Why are you skipping thinking about using stored procedures when you have yet to even define the basic means for inserting this data in to the database? You really need to think about how you are going to map that data structure to your database and what individual queries would need to be done to perform the entire data insert before you even worry about whether you need a stored procedure for this. Commented Dec 5, 2012 at 20:53

1 Answer 1

3

I've used Statement for this issue.

stmnt = conn.createStatement();
conn.setAutoCommit(false);

stmnt.addBatch("insert statement for categories");
stmnt.addBatch("insert statement for skins");
stmnt.addBatch("insert statement for CategorySkins");
...

stmnt.executeBatch();
conn.commit();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.