本文介绍了数据库连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何建立与Java应用程序的SQL 2005数据库连接.实际上,我不知道如何为JDBC设置路径.任何帮助都会很棒.
How to establish SQL 2005 database connectivity with Java application. Actually I don't know how to set path for JDBC. Any help would be great.
推荐答案
- 从 http://下载jdbc驱动程序www.microsoft.com/sqlserver/2005/en/us/java-database-connectivity.aspx .
- 您可以下载Windows或Unix版本.使用哪一个都没关系.
- 如果选择Windows版本,请运行下载的exe文件;否则,请执行以下操作.这将在您将文件下载到的目录中创建一个名为Microsoft SQL Server 2005 JDBC驱动程序的目录.
- 将文件
Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.2\enu\sqljdbc.jar
添加到类路径中(使用java
的-cp
选项,或者,如果使用的是应用服务器,则将其放置在适当的目录中). - 设置您的连接.基本上,所需的信息是:
- 驱动程序类名称:
com.microsoft.sqlserver.jdbc.SQLServerDriver
- 连接网址:
jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]
- 驱动程序类名称:
- Download the jdbc driver from http://www.microsoft.com/sqlserver/2005/en/us/java-database-connectivity.aspx.
- You can either download the Windows or Unix version. It does not really matter which one you use.
- If you chosed the Windows version, run the downloaded exe file; this will create a directory called Microsoft SQL Server 2005 JDBC Driver in the directory you downloaded the file to.
- Add the file
Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.2\enu\sqljdbc.jar
to your classpath (either using the-cp
option ofjava
or, if you are using an application server, by putting it in the appropriate directory). - Set your connection. Basically, the information required for this are:
- the driver class name:
com.microsoft.sqlserver.jdbc.SQLServerDriver
- the connection url:
jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]
- the driver class name:
检查使用JDBC驱动程序连接到SQL Server 获取更多详细信息和/或help
目录中可用的资源(示例代码在help/samples/connections/ConnectURL.java
中提供).
Check Connecting to SQL Server with the JDBC Driver for more details and/or the resources available in the help
directory (sample code available in help/samples/connections/ConnectURL.java
).
这篇关于数据库连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!