使用Java SE 6和Tomcat 6进行JDBC安装和配置-请帮助 [英] JDBC install and configuration with Java SE 6 and Tomcat 6 - help please

查看:106
本文介绍了使用Java SE 6和Tomcat 6进行JDBC安装和配置-请帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Tomcat和Java SE 6的新手,需要了解安装,配置和使用Microsoft JDBC驱动程序所需做的事情.

I am new to Tomcat and Java SE 6 and need to know what I need to do to install, configure and use the Microsoft JDBC driver.

我已经下载了JDBC驱动程序并将其解压缩到Windows 2008系统上的目录中.我将在tomcat 6中安装几个Java应用程序,这些应用程序需要与SQL数据库进行通信.

I have download the JDBC driver and extracted it to a directory on a windows 2008 system. I am going to install a couple of Java applications into tomcat 6 that need to talk to a SQL database.

是否需要将文件从JDBC目录复制到tomcat目录或tomcat中安装的Java应用程序目录?

Do I need to copy files from the JDBC directory to the tomcat directories or the java application directories installed in tomcat?

我是否需要配置任何其他内容?

Do I need to configure any anything anything else?

推荐答案

正如Gagandeep提供的链接所述,为了使JVM建立数据库连接,JDBC驱动程序jar必须位于类路径上,并且您需要为Java程序提供适当的连接字符串和凭据.

As the links that Gagandeep provided will say, in order for your JVM to make a database connection, the JDBC driver jar(s) have to be on the classpath, and you'll need to provide your Java program with an appropriate connection string and credentials.

就您需要特别使用Tomcat进行的操作而言,这很大程度上取决于您的应用程序以及它们如何检索与数据的连接b

As far as what you need to do specifically with Tomcat, that depends quite a bit on your applications and how they retrieve a connection to the datab

现在,有几个选项可以创建和提供此连接.使用Tomcat和Java EE应用程序,您的Java应用程序可以在其web.xml中定义一个. Tomcat将负责创建/维护连接(池),并根据需要将其提供给应用程序.在这种情况下,驱动程序必须位于Tomcat的类路径上,您需要在应用程序的相应context.xml中甚至可能在server.xml中进行一些配置. 有关此方法主题的一些Tomcat文档

Now there are a few options as far creating and providing this connection. With Tomcat and Java EE applications, your Java application could define a in its web.xml. Tomcat would be responsible for creating/maintaining the connection (pool) and providing it to the application as needed. In this case the driver would have to be on Tomcat's classpath, you'd need some configuration in your application's corresponding context.xml and possibly even the server.xml. Here's some Tomcat docs on this method topic

或者,您的应用程序可能负责建立和断开数据库连接,在这种情况下,驱动程序jar可能属于WAR/WAR类路径的一部分.然后,所需要做的就是将所需的连接信息获取到应用程序中的方法(环境条目,属性文件,许多其他方法)...

Alternatively, your application could be responsible itself for setting up and tearing down the database connections, in which case the driver jars probably belong in the WAR / part of the WAR's classpath. Then all that is needed is a method for getting the required connection information into the application (environment entries, property files, any number of other methods)...

这篇关于使用Java SE 6和Tomcat 6进行JDBC安装和配置-请帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆