3. 在MySQL上建立两个数据库
在MySQL数据库中运行SQL脚本,建立topicdb和postdb两个数据库,在topicdb数据库中创建t_topic表,在postdb数据库中创建t_post表。我们希望在这两个数据库上进行JTA事务。SQL脚本如下所示:
/**//*=========创建topicdb数据源及t_topic表==============*/ DROP DATABASE IF EXISTS topicdb; CREATE DATABASE topicdb DEFAULT CHARACTER SET utf8; USE topicdb; drop table if exists t_topic; create table t_topic ( topic_id int(11) not null auto_increment, forum_id int(11) not null default 0, topic_title varchar(100) not null default '', user_id int(11) not null default 0, topic_time datetime default NULL, topic_views int(11) default 1, topic_replies int(11) default 0, primary key (topic_id) ); create index IDX_TOPIC_USER_ID on t_topic ( user_id );
DROP DATABASE IF EXISTS postdb; CREATE DATABASE postdb DEFAULT CHARACTER SET utf8; USE postdb; create table t_post ( post_id int(11) not null auto_increment, topic_id int(11) not null default 0, forum_id int(11) not null default 0, user_id int(11) not null default 0, post_text text, post_attach blob, post_time datetime default NULL, primary key (post_id) ); create index IDX_POST_TOPIC_ID on t_post ( topic_id );
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
相关专题
- 网络管理实用手册 (22482篇文章)
- Spring开源框架技术 (672篇文章)
- Spring开发技术篇 (295篇文章)
- J2SE综合:浅谈java程序发布之 jre 篇 (11次浏览)
- JAVA代码中使用魔法数值 (8次浏览)
- Hibernate缓存管理 (6次浏览)
- JAVA代码应该流畅和结构化 (5次浏览)
- Java JVM设置对性能的影响 (4次浏览)
- 开发框架:深入了解 Struts Validator (3次浏览)
- Java中的通信机制及与C/C API的集成 (1次浏览)
- 用Hibernate实现领域对象的自定义字段 (1次浏览)
- Java语言入门 简述Java语言回收机制 (0次浏览)
- 2008年Java开发者最迫切的五个期望 (0次浏览)



