欢迎来到天天文库
浏览记录
ID:56320743
大小:72.00 KB
页数:20页
时间:2020-06-11
《本例需要的件和运行环境.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、本例需要的软件和运行环境:1、Windows2000Server操作系统2、jdk1.43、JCreator2.5(java源码编辑调试器,吐血推荐!)4、MacromediaJRunMX5、MacromediaDreamweaverMX(非必需)6、MySQL数据库(最好安装MySQLControlCenter)一、数据库设计用MySQLControlCenter打开MySQL数据库,新建数据库shopping,在其下新建表tbl_user,其中各字段设置如下:二、编写连接数据库bean:DBConn.java//DBConn.java//includerequiredclasse
2、simportjava.sql.*;//==========================================//DefineClassDBConn//==========================================publicclassDBConn{publicStringsql_driver="org.gjt.mm.mysql.Driver";publicStringsql_url="jdbc:mysql://localhost:3306";publicStringsql_DBName="shopping";publicStringuser="s
3、a";publicStringpwd="";Connectionconn=null;Statementstmt=null;ResultSetrs=null;publicbooleansetDriver(Stringdrv){this.sql_driver=drv;returntrue;}publicStringgetDriver(){returnthis.sql_driver;}publicbooleansetUrl(Stringurl){this.sql_url=url;returntrue;}publicbooleansetDBName(Stringdbname){this.sq
4、l_DBName=dbname;returntrue;}publicStringgetDBName(){returnthis.sql_DBName;}publicbooleansetUser(Stringuser){this.user=user;returntrue;}publicStringgetUser(){returnthis.user;}publicbooleansetPwd(Stringpwd){this.pwd=pwd;returntrue;}publicStringgetPwd(){returnthis.pwd;}publicDBConn(){try{Class.for
5、Name(sql_driver);//加载数据库驱动程序this.conn=DriverManager.getConnection(sql_url+"/"+sql_DBName+"?user="+user+"&password="+pwd+"&useUnicode=true&characterEncoding=gb2312");this.stmt=this.conn.createStatement();}catch(Exceptione){System.out.println(e.toString());}}//执行查询操作publicResultSetexecuteQuery(St
6、ringstrSql){try{this.rs=stmt.executeQuery(strSql);returnthis.rs;}catch(SQLExceptione){System.out.println(e.toString());returnnull;}catch(NullPointerExceptione){System.out.println(e.toString());returnnull;}}//执行数据的插入、删除、修改操作publicbooleanexecute(StringstrSql){try{if(this.stmt.executeUpdate(strSql
7、)==0)returnfalse;elsereturntrue;}catch(SQLExceptione){System.out.println(e.toString());returnfalse;}catch(NullPointerExceptione){System.out.println(e.toString());returnfalse;}}//结果集指针跳转到某一行publicbooleanrs_absolute(introw){try{this
此文档下载收益归作者所有