*Java EE 项目案例

Java EE 项目案例
运行环境
Tomcat  5.5,MySQL  5.0.45
Eclipse SDK  3.2
Spring 2.0
Hibernate 3.0

现有项目到工作空间中导入下面几个项目
数据库目录复制到“mysql安装根目录“

Buy演示购物:  Java+JavaBeans ^     

第2章的示例程序。
Lab:科研 新闻发布  ^ servlet取代action之前;自建标签   

 第3章的示例程序。
NoticeManager: ^   第4章的示例程序。
BBS:      第5章的示例程序。
BookStore: ^    第6章的示例程序。
Individuation: ^ Ajax+spring  第7章的示例程序。
MyStuMan: ^ (数据库在hibernate的配置错误,不会出现

Servlet action is not available) hiber+struts+log4j   

第8章的示例程序。
FileManager: ^(数据库连接在struts中配置错误,会出现servlet action is

available的提示)   第9章的示例程序。
OrderTickets: 文件找不到404错误,怎么回事   第10章的示例程序。


-1
<jsp:useBean id="selectaddcoinBean"
 class="com.buy.bean.coin.AddcoinSelectBean" scope="request">
</jsp:useBean>
<jsp:setProperty name="selectaddcoinBean" property="s_year"
 param="s_year" />  文本框的字段名字是"s_year"
这样设置的好处,就是不用在用request来取文本框的值   
—2
action="<%=basePath%>/add_teacher"

<jsp-config>
  <taglib>
  <taglib-uri>control</taglib-uri>
  <taglib-location>/WEB-INF/mytag.tld</taglib-location>
 </taglib>
<%@ taglib uri="control" prefix="control"%>
<control:news4news />


-3
Servlet action is not available (十有八九是配置文件错误)
Action连接数据库出问题会报这种错误(driverClassName,url,用户密码,驱动

包等原因)Action中使用noticemanagerDB来连接数据库
 <data-sources>
  <data-source key="noticemanagerDB"
   

type="org.apache.commons.dbcp.BasicDataSource">
   <set-property property="driverClassName"
    value="com.mysql.jdbc.Driver" />
   <set-property property="url"
    

value="jdbc:mysql://localhost:3307/noticemanager" />
   <set-property property="username"

value="root" />
   <set-property property="password"

value="root" />
  </data-source>
 </data-sources>
要先测试一下
try {
   String name = "com.mysql.jdbc.Driver";
   String url =

"jdbc:mysql://localhost:3307/noticemanager?                                            

         useUnicode=true&characterEncoding=gb2312";
   Class.forName(name).newInstance();
   Connection con =

DriverManager.getConnection(url, "root", "root");
   System.out.println("连接MySQL 5.0.18成功!(驱

动3.1.8)");
   PreparedStatement pStmt = null;
   ResultSet rs = null;
   int id = 0;
   String title = null;
   String content = null;
   String strSql = new String("SELECT * FROM

notice");
   try {
    pStmt = con.prepareStatement(strSql,
      

ResultSet.TYPE_SCROLL_INSENSITIVE,
      

ResultSet.CONCUR_READ_ONLY);
    rs = pStmt.executeQuery();
    if(rs.next()) {
     id = Integer.parseInt

(rs.getString("ID"));
     title = rs.getString("Title");
     title = new String

(title.getBytes("ISO-8859-1"), "GB2312");
     content = rs.getString

("Content");
     content = new String

(content.getBytes("ISO-8859-1"), "GB2312");
     System.out.println(id);
     System.out.println(title);
     System.out.println(content);
    }
   } finally {
    try {
     rs.close();
     pStmt.close();
     con.close();
    } catch (Exception e) {
     e.printStackTrace();
    }
   }

  } catch (Exception e) {
   e.printStackTrace();
  
}

*这章怎么连接数据库的哪,有多个地方?
DB db = new DB(DBUtil.connectToDB()); DBUtil中有设置数据名等。。

---4

 

————————————————————————————————————
  如果你的工作时间是固定的
SimpleDateFormat myFormat=new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = Calendar.getInstance();

//当前日期后7天的日期
cal.add(Calendar.DATE, 7);

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值