Javaweb网上商城项目实战(4)项目环境搭建

创建项目

创建一个动态网站项目store_v1,创建步骤略。并建立如下目录结构

导入jar包

项目jar包如下,导入即可

添加工具类

这些工具类已经写好了,拿来用就可以了。

[dm href=’https://www.jikewenku.com/project/1715.html’]查看工具类源码[/dm]

导入c3p0配置文件

根据自己情况修改如下内容


	
	
		com.mysql.jdbc.Driver
		jdbc:mysql://localhost:3306/store_01
		root
		root
		30000
		30
		10
		30
		100
		10
		200
		
			10
			1
			0
		
	 
	
	
		com.mysql.jdbc.Driver
		jdbc:mysql://localhost:3306/store_01
		root
		root
    
		5
		20
		10
		40
		0
		5
	

接下来测试一下是否能连上数据库,在JDBCUtils.java里,run as java application,如果输出如下所示就连上了

编码过滤器

复制EncodeingFilter.java到web包下的filter里,这里顺便把我们之前写的BaseServlet工具类也导入,导入到web包下的base里。

在web.xml里配置一下过滤器


    EncodingFilter
    cn.itcast.store.web.filter.EncodingFilter
  
  
    EncodingFilter
    /*
  

导入jsp页面

复制我们提供的JSP页面原型,导入到WebContent目录下

运行项目

接下来就可以运行一下项目了,如果成功运行了就可以进行接下来的开发了,如果有问题有错误请自己检查或者在下面留言。

源码下载

[dm href=’https://www.jikewenku.com/product/1700.html’]下载地址[/dm]

本站所有文章均由网友分享,仅用于参考学习用,请勿直接转载,如有侵权,请联系网站客服删除相关文章。若由于商用引起版权纠纷,一切责任均由使用者承担
极客文库 » Javaweb网上商城项目实战(4)项目环境搭建

1 评论

  1. 正常配置C3P0和JDBCUtils.java后
    Exception in thread “main” java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.
    at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
    at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:65)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:639)
    at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
    at com.geekerstar.store.utils.JDBCUtils.getConnection(JDBCUtils.java:24)
    at com.geekerstar.store.utils.JDBCUtils.main(JDBCUtils.java:129)
    Caused by: com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@1b0375b3 — timeout at awaitAvailable()
    at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1404)
    at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:594)
    at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:514)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:707)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:634)
    … 3 more

Leave a Reply

欢迎加入「极客文库」,成为原创作者从这里开始!

立即加入 了解更多