当前位置: 代码迷 >> Java Web开发 >> 期終考試題目,國外朋友的,俺不會jsp只好請教大大門,该怎么解决
  详细解决方案

期終考試題目,國外朋友的,俺不會jsp只好請教大大門,该怎么解决

热度:62   发布时间:2016-04-17 16:04:49.0
期終考試題目,國外朋友的,俺不會jsp只好請教大大門
分數好説話
A. JavaBean   for   retrieving   information   from   a   database.
Create   a   JavaBean   (say   dbConnector.java)   that   connects   to   a   database   and   retrieves   and   holds   information,   based   on   a   given   SQL   query   string   input.
创建一个基于SQL   query   string   的输入的JavaBean   用来连接数据库并且检索和储存信息,

a. The   bean   should   have   the   following   functionality   实现如下功能:
i. A   function   called   connect(url,   driver,   username,   password)   that   takes   four   String   parameters:   url,   driver,   username,   password;   and   then   connects   to   the   given   database.   By   default   (when   the   JavaBean   is   instantiated   对象初始化时),   the   JavaBean   should   use   the   database   connection   settings   specified   in   the   NOTE   1   below   用注释1的值.
ii. A   function   called   executeSQL(sql)   that   executes   “select”   type   SQL   queries.   The   function   takes   one   String   parameter,   an   SQL   query,   and   it   then   executes   that,   and   stores   the   results   within   a   private   variable   私有变量   in   a   表格格式tabular   format   (e.g.   2D   Array,   or   Vector   of   Objects   (which   Object   may   be   another   Vector),   or   ArrayList   of   Objects,   or   anything   else   that   better   meets   your   needs).
iii. A   function   called   updateSQL(sql)   that   updates,   or   inserts,   or   deletes,   records   from   the   database.   The   function   takes   one   String   parameter,   an   SQL   query,   and   it   then   executes   that,   and   returns   the   number   of   records   affected   by   the   update.
iv. A   function   called   getHeader(id)   which   takes   one   int   parameter,   the   column   id,   and   returns   as   String   the   header   name   at   the   given   column   location.
v. A   function   called   getRecord(row,   col)   which   takes   two   int   parameters,   the   column   id,   and   the   row   id,   and   returns   as   an   Object   the   record   at   the   given   cell   location.
vi. Other   functions   that   you   may   find   useful;   like   functions   that   return   the   number   of   columns   or   number   or   rows,   or   functions   that   clear   the   local   variables   (holding   record   information)   in   case   you   want   to   run   a   new   SQL   query.

NOTE   1:   There   will   be   (from   week   7   onwards)   a   MySQL   database   available   within   the   University   and   each   enrolled   student   will   have   access   to   it.   To   connect   to   the   database   use   the   following   settings:
  相关解决方案