Tomcat中web.xml配置数据库和servlet的配置
来源:互联网 发布:数据库小项目 编辑:程序博客网 时间:2024/05/27 21:49
#配置Tomcat数据源
1.context.xml文件的配置
Resource name=”jdbc/news”
auth=”Container” type=”javax.sql.DateSource” maxActive=”100”
maxIdle=”30” maxWait=”100” userName=”root” password=”980211”
driverClassName=”com.mysql.jdbc.Driver”
url=”“/>
2.配置web.xml文件
news
javax.sql.DataSource
Container
3.添加驱动
添加数据库启动包(jar包)到Tomcat的lib目录下
4.进行代码编写,使用Lookup()方法获得数据源对象
ctx=new InitialContext();
DataSource ds=(DataSource)ctx.lookup(“java:comp/env/news”);
conn=ds.getConnection();
servlet的配置:在web.xml文件中 <servlet> <!--名字自取 最好与类名一致--> <servlet-name>LoginCheck</servlet-name> <!--servlet的类的路径--> <servlet-class>com.cs.test.LoginCheck</servlet-class> </servlet><servlet-mapping> <servlet-name>LoginCheck</servlet-name> <!--访问路径--> <url-pattern>/LoginCheck</url-pattern></servlet-mapping>**
阅读全文
1 0
- Tomcat中web.xml配置数据库和servlet的配置
- Servlet容器Tomcat中web.xml中servlet 和 servlet-mapping 标签的配置
- Servlet中web.xml的配置解析
- web.xml中servlet的配置
- Servlet中Web.xml的配置详解
- servlet中web.xml的配置
- web.xml中servlet的配置
- web.xml中servlet-mapping的配置
- Servlet中Web.xml的配置详解
- Servlet中Web.xml的配置详解
- Servlet中Web.xml的配置详解
- web.xml中servlet-mapping的配置
- Servlet中Web.xml的配置详解
- Servlet中Web.xml的配置详解
- Servlet中Web.xml的配置
- web.xml中servlet-mapping的配置
- web.xml中servlet的配置
- web.xml中servlet的配置
- Android中弹窗中带有Edittext,软键盘遮挡问题
- Apache负载均衡配置
- 【JAVA多线程】-线程的两种创建方式及比较
- 6.29
- java 内存回收管理机制——Reference中四种引用方式
- Tomcat中web.xml配置数据库和servlet的配置
- Optical.Research.Associates.LightTools.v5.1.incl.SP1光学工程软件
- Beebird的小e体验板学习历程2
- com.microsoft.sqlserver.jdbc.SQLServerException: 不支持此服务器版本。目标服务器必须是 SQL Server 2000 或更高版本。
- Sql学习(5)——Mysql数据库ROUND()函数
- 6.30
- C++入门基础知识
- spring-cloud demo
- 机器学习之numpy和matplotlib学习(十)