简体   繁体   English

SQL Server 2005:如何在平台jboss 3.0上连接到SQL Server 2005?

[英]sql server 2005:how to connect to sql server 2005 on platform jboss 3.0?

i have deployed my application on jboss 3.I have restored a database back up of sql server 2000 on sql server 2005.then i have downloaded the jr file jdbc connection to sql server 2005.My connection string setting is as below. 我已经在jboss 3上部署了我的应用程序,我已经在sql server 2005上恢复了sql server 2000的数据库备份,然后我将jr文件jdbc connection下载到了sql server 2005.我的连接字符串设置如下。

    <datasources>
<local-tx-datasource>
    <jndi-name>SLBDataSource</jndi-name>
    <connection-url>jdbc:sqlserver:\\RAVIGARG\SQLSERVER2005;DatabaseName=Sahil_test_12_12_09;SelectMethod=cursor</connection-url>
    <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>

    <min-pool-size>10</min-pool-size>
    <max-pool-size>100</max-pool-size>
    <user-name>sa</user-name>
    <password>sa</password>
</local-tx-datasource>

But i am getting exception as below. 但是我得到如下异常。

    WARN  [JBossManagedConnectionPool] Throwable while attempting to get a new      connection:
       org.jboss.resource.JBossResourceException: Could not create connection; -  nested  throwable: (java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]   Unable to connect.  Invalid URL.)

According to Building the Connection URL , the general form of a connection url is 根据构建连接URL连接URL的一般形式为

jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]

So, if RAVIGARG is ther server name, try something like this instead (note the forward slashes): 因此,如果RAVIGARG是该服务器的名称,请尝试这样的操作(注意正斜杠):

jdbc:sqlserver://RAVIGARG\SQLSERVER2005;databaseName=Sahil_test_12_12_09;SelectMethod=cursor

PS: According to the stracktrace, you are using a JDBC driver for SQL Server 2000. This is not the root cause of the problem but maybe you should consider upgrading it as you are using SQL Server 2005. If you do so, note that the driver class name is com.microsoft.sqlserver.jdbc.SQLServerDriver so update your <driver-class> accordingly. PS:根据stracktrace的说明,您正在为SQL Server 2000使用JDBC驱动程序。这不是问题的根本原因,但是也许您应该在使用SQL Server 2005时考虑对其进行升级。如果这样做,请注意驱动程序类名称为com.microsoft.sqlserver.jdbc.SQLServerDriver,因此请相应更新您的<driver-class> See SQL Server 2005 JDBC Driver Documentation . 请参阅SQL Server 2005 JDBC驱动程序文档

Just a suggestion: you might want to use jTDS instead. 只是一个建议:您可能想改用jTDS It is much more stable than Microsoft's drivers, delivers great performance and works with all kinds of flavors of SQL Server. 它比微软的驱动程序稳定,可提供卓越的性能和各类的SQL Server口味的作品。 We've been using it on our production servers for years. 多年来,我们一直在生产服务器上使用它。

This would be the appropriate connect string: 这将是适当的连接字符串:

jdbc:jtds:<server_type>://<server>[:<port>][/<database>][;<property>=<value>[;...]]

You can find out everything about driver names etc. in the jTDS FAQ . 您可以在jTDS FAQ中找到有关驱动程序名称等的所有信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM