日期:2014-05-16 浏览次数:20460 次
DROP TABLE IF EXISTS `school`.`student`;
?
CREATE TABLE `school`.`student` (
`id` int(11) NOT NULL default '0',
`name` varchar(20) default NULL,
`sex` varchar(10) default NULL,
`age` int(10) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
?
INSERT INTO `student` VALUES ('201201', '张三', '男', '21');
INSERT INTO `student` VALUES ('201202', '李四', '男', '22');
INSERT INTO `student` VALUES ('201203', '王五', '女', '20');
INSERT INTO `student` VALUES ('201204', '赵六', '男', '21');
INSERT INTO `student` VALUES ('201205', '小红', '女', '19');
INSERT INTO `student` VALUES ('201206', '小明', '男', '22');
??? 【示例代码 】
?
package com.hebut.util;
?
public class DBHelperApp {
?
??? /**
???? * 增加【 Add 】
???? */
??? public static void main(String[] args) {
??????? // 第一种情况
??????? String sql1="Insert Into student Values ('201208', ' 张三 ', ' 男 ', '21')";
??????? System.out .println(DBHelper.executeNonQuery (sql1));
???????
??????? // 第二种情况
??????? String sql2="Insert Into student Values (?,?,?,?)";
??????? Object[] obj = new Object[]{"201209"," 张三 ", " 男 ", "21"};