下載後導入項目到 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=GBK insert 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);