tomcat使用数据源和连接池技术连接Sql server数据库

Tomcat通过JNDI方式连接SqlServer数据库 Tomcat通过JNDI方式连接SqlServer数据库 开发JSP详解 立即下载

一、综述

一共要做两方面的配置:1.在tomcat的conf目录下找到server.xml文件,对其进行配置。

2.在你的web-app下的WEB-INF目录下找到你网站的web.xml文件进行配置。

3.本人使用的环境:apache-tomcat-6.0.43,SQL server 2008

二、server.xml配置

样例:<resource-ref>  
      <res-ref-name>myWebSite</res-ref-name>  
      <res-type>javax.sql.DataSource</res-type>  
      <res-auth>Container</res-auth>  
    </resource-ref> 

三、server.xml的配置

<Context path="/cl" docBase="d:\MyWebSite" debug = "0" reloadable="true">
<Resource name="myWebSite" 
auth="Container" type="javax.sql.DataSource" 
maxActive="100" maxIdle="30" maxWait="1000" 
username="sa" password="123" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" 
url="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=mydb"
/>
   </Context>

*:这里只是给出简单样例,其中两个文件中的红色加粗内容(myWebSite)必须一样,当然你可以用其他名字,但必须一样

另给出一个详细的解释:Tomcat下配置数据源连接数据库

5G核心网Framed Routing功能解析:基于PFCP的帧路由机制与多终端互联实践 阅读详情

相关推荐

基于PlatformIO与CMSIS的STM32库函数开发实战:从环境搭建到外设驱动

本文详细介绍了基于PlatformIO与CMSIS的STM32库函数开发实战,从环境搭建到外设驱动实现。通过对比传统IDE,PlatformIO结合CMSIS框架在跨平台开发、代码可移植性和调试体验上更具优势。文章包含PlatformIO.ini配置详解、GPIO/USART驱动开发实例及常见问题解决方案,帮助开发者高效完成STM32项目开发。

weixin_29190169的博客 430

通过Tomcat连接池连接SQL Server数据库

配置Tomcat连接池主要使用的是标签,下面对本实例中用到标签中的属性进行详细讲解。 (1)name:数据库连接池名称。 (2)type:数据库连接池类型。 (3)driverClassName:使用的JDBC驱动的完整有效的java类名。 (4)url:传递给JDBC驱动的用于建立连接的URL。 (5)username:传递给JDBC驱动的用于建立连接的用户名。 (6)passw

考拉的专栏 7008

windows sever2019切换Linux内核

安装docker engine后,内核是windows,很多镜像都无法安装使用。 一,在https://github.com/linuxkit/lcow/release 下载最新版本release.zip,我使用了如下版本。 二,新建文件夹C:\Program Files\Linux Containers ,把release.zip(不要解压)放入此文件夹 三,编辑docker配置文件( C:\ProgramData\docker\config\daemon.json) ,电脑中没有该文件,新建一

记录日常疑问 3877

Java使用tomcat连接Sql server 2008数据库

1.连接语句 //连接数据库 Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); //得到连接 ct = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;DatabaseName=数据库名;user=用户名;password=密码;"); /

casy35的专栏 2756

如何用ISBN API快速获取图书信息?Python实战教程(附完整代码)

本文是一篇Python实战教程,详细介绍了如何利用ISBN API高效获取图书元数据。内容涵盖从API服务选择、密钥管理,到使用requests库构建健壮的请求模块,并利用Pydantic进行数据验证与解析。教程还提供了批量查询、缓存优化及集成到Flask Web应用等高级技巧,帮助开发者快速实现图书信息的自动化获取与处理。

p8q9r0的博客 459

从RadixTree到哈希表:深入对比SGLang和vLLM的Prefix Cache实现差异

本文深入对比了SGLang与vLLM在大语言模型推理服务中实现Prefix Cache(前缀缓存)的两种核心方案。SGLang采用基于Radix Tree的RadixAttention,支持任意长度前缀的精确匹配与灵活复用;vLLM则采用基于哈希表的方案,深度集成于PagedAttention,实现简洁但要求块级精确对齐。文章剖析了二者在设计哲学、内存管理、适用场景及集群级优化(如Prefix Cache Aware Routing)上的关键差异,为高性能LLM服务的技术选型提供决策依据。

blockchain9miner的博客 964

tomcat连接sqlserver配置

一、项目(虚拟目录)下web-inf/conf.xml文件中的数据库配置&lt;database&gt;  &lt;!--数据库相关配置,logfile为连接池的日志文件      maxconnection为连接池的最大值--&gt;  &lt;!-- &lt;poolfor&gt;新闻发布&lt;/poolfor&gt;  &lt;poolname&gt;newsconnpool&lt;/po...

weixin_34029949的博客 1136

【硬刚Hive】HIVE基础(20):Hive函数(9) over 窗口函数

欢迎关注博客主页:微信搜:import_bigdata,大数据领域硬核原创作者_王知无(import_bigdata)_CSDN博客 欢迎点赞、收藏、留言 ,欢迎留言交流!本文由【王知无】原创,首发于 CSDN博客!本文首发CSDN论坛,未经过官方和本人允许,严禁转载! 本文是对《【硬刚大数据之学习路线篇】从零到大数据专家的学习指南(全面升级版)》的Hive部分补充。 hive窗口函数语法 在前言中我们已经说了avg()、sum()、max()、min()是分析函数,而over()才是窗..

微信搜:import_bigdata,大数据领域硬核原创作者 890

Tomcat配置SQLServer连接池

进入tomcat目录下的conf文件夹目录里,找到Server.xml 在tomcat的Server.xml文件中在标签与标签里,定议连接语句,格式如下 ...

JGambler的专栏 1087

EtherCAT用TwinCAT 3跑DC报0x2C或者0x1A错误码

EtherCAT用TwinCAT 3跑DC报0x2C或者0x1A DC报错 ///////////////////////////////////////////////////////////////////////////////////////// /** \brief Checks communication and synchronisation variables and update AL status / AL status code if an error has occurr

PI_sunyang的博客 5317

Vue3 - Arco Design Vue 表格组件 table 隐藏鼠标移入时 hover 高亮背景色,el-table 组件去除鼠标悬停在表格行的 hover 高亮效果(改变鼠标移入时的背景色)

vue3,arcodesignvue,arcodesign,表格,a-table,hover,表格hover的class类名是什么,class,hover,在arcodesignvue项目中,表格组件如何去掉鼠标移入时的hover效果,vue3arco.design表格组件修改鼠标移入行的背景颜色,table表格,取消表格行row移入高亮效果,去掉鼠标移入行时的hover效果,取消a-table的hover状态,取消高亮显示,隐藏表格鼠标hover效果,去除鼠标触摸变色效果,如何取消arco表

🏆 前端领域优质创作者 3778

如何连接SQL Server数据库(Tomcat 连接池配置) (转载)

 1. 通过Microsoft的JDBC驱动连接。此JDBC驱动共有三个文件,分别是mssqlserver.jar、msutil.jar和msbase.jar,可以到微软的网站去下载(http://www.microsoft.com/downloads/details.aspx?FamilyId=07287B11-0502-461A-B138-2AA54BFDC03A&displaylang=

wengax的专栏 2594

(功能安全六)硬件FMEDA计算

FMEDA(故障模式、影响与诊断分析)是功能安全验证的核心方法,通过量化分析硬件故障模式及其影响,计算SPFM、LFM、PMHF等关键指标。分析过程包含六大步骤:计算元器件失效率、识别故障模式、评估安全机制诊断覆盖率、分类计算各类失效率、量化指标计算及设计优化。输入需要系统架构图、硬件故障模式清单等资料,输出安全指标达标情况及改进建议,确保设计满足ASIL等级要求。该方法通过系统化的故障分类和量化评估,为硬件安全设计提供科学依据。

Dayongger的博客 1468

tomcat数据库连接池的技术整理(支持oracle、sql server)

tomcat数据库连接池的技术整理(支持oracle、sql server)

WYZSC的专栏 3348

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

tomcat配置mysql和sqlserver连接池

1.在tomcat的conf目录下修改context.xml <Resource name="jdbc/mysql" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="root" password="websuntek716mysql"

a19860903的专栏 1994

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

tomcat容器下配置数据库连接池并测试

数据库连接是一种关键的有限的昂贵的资源,这在多用户网页应用程序中体现的尤为突出.对数据库连接的管理能显著影响到整个应用程序的伸缩性和健壮性,影响到程序的性能指标,数据库连接池正是针对这个问题提出的 数据库连接池负责分配,管理和释放数据库连接,它允许应用程序重复使用一个现有的数据库连接,而不是再重新建立一个;释放空闲时间超过最大空闲时间的数据库连接来避免因为没有释放数据库连接而引起的数据库连接遗漏...

云淡风轻 1859

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

Tomcat5数据源配置(转载)

给出一个tomcat5配置 常见数据库连接池的例子.环境: w2kp sp4,   jsdk1.4.2_8; tomcat5.0.2.8; oracle817, sqlserver2000 sp3 , mysql5 beta总的来说在tomcat配置一个数据源有4项工作要做.    1. 在server.xml 里配置数据源连接池参数。 可以手动,也可以通过tomcat admin工具。   2.

小蚂蚁窝 2833

Tomcat 5和WebLogic 8数据源的配置和使用

Weblogic数据源配置启动服务器和数据库. 进入控制台,选择左侧组件树的 Services > JDBC > Connection Pools 选择数据库类型 定义连接属性(URL等) 测试数据库连接 连接池配置结束. 连接池在JNDI上没有显示信息. 配置数据源绑定到JNDI上. JNDI 路径区分

376

Tomcat中使用jndi例子

说明:       主要使用jndi对tomcat中的 env 以及 source 进行调用问题:        .注意 jdbc驱动需要放在 ${CATALINA_HOME}/common/lib 目录下         在tomcat的配置文件中需要注意 标签的次序问题#server.xml的配置如下                                          facto

Studying & Summarizing 2864

配置数据源和数据连接池

在实际项目的开放中,特别是Web应用程序中,如Jsp,Servlet或EJB使用JBDC直接范围数据库中的数据,每一次数据方请求必须 建立连接,存取数据,关闭连接等步骤,而数据连接是一种非常昂贵的资源,繁琐的建立连接,关闭连接必定是数据库性能降低,再者 JDBC直接连接数据库的方式还存在数据库连接漏洞问题。使用数据库连接池计算是解决上述问题的最常用方法。

st_linxiaoling的专栏 1080

jndi连接数据库

通过JNDI连接数据库<br />tomcat6.0 连接池的配置<br />  <Resource name="jdbc/DBPool"  <br />       auth="Container"  <br />       type="javax.sql.DataSource"  <br />       driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"  <br />       url="jdbc:microsoft:sq

liushine2010的专栏 589

数据库JDBC连接

下面罗列了各种数据库使用JDBC连接的方式,可以作为一个手册使用。... 2 数据库连接池的应用。... 6 一、Tomcat配置数据源:... 15 二、Hibernate配置连接池有三种方法:... 17 一、Hibernate 连接池:C3P0 配置... 21

yaminvsasheng的专栏 853

JNDI学习总结(二)——Tomcat下使用C3P0配置JNDI数据源

一、C3P0下载   C3P0下载地址:http://sourceforge.net/projects/c3p0/files/?source=navbar      下载完成之后得到一个压缩包。 二、使用C3P0配置JNDI数据源   Tomcat6.x中配置JNDI数据源时默认使用的是Tomcat6.x自带的DBCP连接池,Tomcat6.x使用DBCP连接池配置J

houbin0912的博客 486

论文中mysql怎么简洁_哪个给个简单数据库建立的例子(论文形式)

展开全部给你这个网址,去看看http://secondary.114study.com/环境: w2kp sp4, jsdk1.4.2_8; tomcat5.0.2.8; oracle817, sqlserver2000 sp3 , mysql5 beta总的来说在tomcat配置一个数据源有4项工作要做.1. 在server.xml 里配置数据源连接池参数e5a48de588b6626169...

weixin_33592736的博客 697

常用数据库 tomcat 配置jdni

Global JNDI resources 2 Documentation at /docs/jndi-resources-howto.html 3 --> 4 GlobalNamingResources> 5 Editable user database that can also be used by 6 UserDatabaseRe

模式情怀的专栏 569

JDBC访问数据库的步骤——实例二

实例二(使用Tomcat数据源连接池):在WebContent / META—INF 文件中配置名为context.xml的文件(实际上就是配置basicDataSourceFactory) <Resource name="jdbc/sqlserver" type="javax.sql.DataSource" driverClassName="com.microsoft.sqlserve

招风的黑耳CSDN 781
上一篇: Java使用tomcat连接Sql server 2008数据库
下一篇: java ee开发时解决中文乱码的工具类(自己备忘)
casy35
博客等级 码龄15年 0粉丝 14原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值