• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1267
  • Last Modified:

Want to create dynamic table with spring and ibatis

I want to create the dynamic table in DAO layer. I need create the table insert the some records and drop the table all these has to happen in DA layer. Please let me know any one has info
  • 2
1 Solution
UmeshMySQL Principle Technical Support EngineerCommented:
In MySQL dynamically tables can be created in this way..
set @table_name := 'mytable';
set @sql_text:=concat('create table ',@table_name,'(id int unsigned)');
PREPARE stmt1 FROM @sql_text;
EXECUTE stmt1;
# Your insert stuff can go here
# Later drop the table

Open in new window

atmohsinAuthor Commented:

I am using the spring+ibatis and mysql server there is DAO layer which interact with DB.

Suppose for updating the result into db we are using following codegetSqlMapClientTemplate().update("updateTestRunSyncStatus", listTestRunIds);

I am not able to get for creating table
suppose i have
String sql="create test (id int,name varchar2(10));
now i need to execute this query.

UmeshMySQL Principle Technical Support EngineerCommented:

Syntax should be
create table test (id int,name varchar(10)

This may help you...


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now