下載後匯入項目到 MyEclipse , 然後修改資料庫連接參數即可測試. 我這用 的是 MySQL 資料庫. 用 JSP 是因為 Hibernate 可以配合各種架構, 因此在代 碼裡我已經盡量的把頁面和背景直接變數耦合分隔開了.
部分代碼顯示:
相關 SQL:
CREATE TABLE `user` ( `id` int(11) NOT NULL, `username` varchar(200) NOT NULL, `password` varchar(20) NOT NULL, `age` int, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=GBK;-- JDBC Driver Name: com.mysql.jdbc.Driver-- JDBC Driver URL: jdbc:mysql://hostname/dbname?useUnicode=true&characterEncoding=GBKinsert into user values(1, '中文', 'beansoft', 1);insert into user values(2, 'BeanSoft', 'beansoft', 2);insert into user values(3, '張三', 'beansoft', 3);insert into user values(4, '李四', 'beansoft', 4);insert into user values(5, '王五', 'beansoft', 5);insert into user values(6, '馬六', 'beansoft', 6);insert into user values(7, '黑七', 'beansoft', 7);insert into user values(8, '臘八', 'beansoft', 8);insert into user values(9, '陸九', 'beansoft', 9);insert into user values(10, '茅十八', 'beansoft', 10);