Topic: 求助:JDBC/MS SQLServer2000的连接配置

  Print this page

1.求助:JDBC/MS SQLServer2000的连接配置 Copy to clipboard
Posted by: tozx96
Posted on: 2003-07-20 23:04

在多数情况下,可以如下获取连接:
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=CreatWall;user=sa;Password=");
但是,我的MS SQLServer2000的服务器串中间有个“\”,形如“soft-nec\zlp”,我的机器名为soft-nec。我把连接串中的localhost分别改成了:soft-nec、soft-nec、soft-nec\zlp、soft-nec\\zlp、localhost,但都不行。我想问题应该是出在我的MS SQLServer2000的服务器串中间有个“\”。请问这种情况下要怎么办?非常谢谢。

2.Re:求助:JDBC/MS SQLServer2000的连接配置 [Re: tozx96] Copy to clipboard
Posted by: why
Posted on: 2003-07-21 01:35

is 127.0.0.1 okay?
are you sure all the 3 jars are in the classpath?

what's the error message?

by the way, it's not a good idea to use an empty password.Smile

3.Re:求助:JDBC/MS SQLServer2000的连接配置 [Re: tozx96] Copy to clipboard
Posted by: redmiddle
Posted on: 2003-07-21 14:17

你试试首先用odbc去连连你机器的sql server.注意,我不是说你要odbc连哦.因为我记得这样机器上的数据库名一样可以连.不是用IP.直接也是机器名.所以有可能你写反了.可能是soft-net/zlp

4.Re:求助:JDBC/MS SQLServer2000的连接配置 [Re: tozx96] Copy to clipboard
Posted by: tozx96
Posted on: 2003-07-21 14:56

谢谢两位。
我用windows2000管理工具中的ODBC连可以连得上,用的是“soft-nec\zlp”。
我用的是jboss-3.2.0_tomcat-4.1.24平台,那些配置信息是写在jboss-3.2.0_tomcat-4.1.24的MSSqlServer2000的JDBC配置文件中(mssql_ds.xml),启动jboss服务时出现了连接错误,错误信息是:
14:46:18,437 ERROR [EntityContainer] Initialization failed
org.jboss.deployment.DeploymentException: Error while checking if table aleady e
xists; - nested throwable: (org.jboss.util.NestedSQLException: Could not create
connection; - nested throwable: (java.sql.SQLException: [Microsoft][SQLServer JD
BC Driver]Error establishing socket.); - nested throwable: (org.jboss.resource.J
BossResourceException: Could not create connection; - nested throwable: (java.sq
l.SQLException: [Microsoft][SQLServer JDBC Driver]Error establishing socket.)))
at org.jboss.ejb.plugins.cmp.jdbc.SQLUtil.tableExists(SQLUtil.java:731)
at org.jboss.ejb.plugins.jaws.jdbc.JDBCInitCommand.execute(JDBCInitComma
nd.java:107)
at org.jboss.ejb.plugins.jaws.JAWSPersistenceManager.create(JAWSPersiste
nceManager.java:131)
at org.jboss.ejb.plugins.CMPPersistenceManager.create(CMPPersistenceMana
ger.java:127)
at org.jboss.ejb.EntityContainer.createService(EntityContainer.java:297)

at org.jboss.system.ServiceMBeanSupport.create(ServiceMBeanSupport.java:
158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
后面还有很多at....


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923