• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1264
  • 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
0
atmohsin
Asked:
atmohsin
  • 2
1 Solution
 
UmeshCommented:
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;
DEALLOCATE PREPARE stmt1;
 
 
# Your insert stuff can go here
 
# Later drop the table

Open in new window

0
 
atmohsinAuthor Commented:
Thanks

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.

0
 
UmeshCommented:


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

This may help you...

http://www.jroller.com/dancruz/entry/spring_dao_integration

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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