eclipse打包的Java代码,在服务器上用tomcat跑,连接sql server2008R2成功,用户 'root' 登录失败。
这是applicationContext.xml配置文件:
<bean name="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="url" value="jdbc:sqlserver://127.0.0.1;DatabaseName=test" />
<property name="username" value="root" />
<property name="password" value="root521" />
<!-- 初始化连接大小 -->
<property name="initialSize" value="0" />
<!-- 连接池最大使用连接数量 -->
<property name="maxActive" value="2000" />
<!-- 连接池最小空闲 -->
<property name="minIdle" value="0" />
<!-- 获取连接最大等待时间 -->
<property name="maxWait" value="60000" />
<!-- <property name="poolPreparedStatements" value="true" />
<property name="maxPoolPreparedStatementPerConnectionSize" value="33" /> -->
<property name="validationQuery" value="SELECT 1" />
<property name="testOnBorrow" value="false" />
<property name="testOnReturn" value="false" />
<property name="testWhileIdle" value="true" />
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name="timeBetweenEvictionRunsMillis" value="6000" />
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name="minEvictableIdleTimeMillis" value="25200000" />
<!-- 打开removeAbandoned功能 -->
<property name="removeAbandoned" value="true" />
<!-- 1800秒,也就是30分钟 -->
<property name="removeAbandonedTimeout" value="1800" />
<!-- 关闭abanded连接时输出错误日志 -->
<property name="logAbandoned" value="true" />
<!-- 监控数据库 -->
<!-- <property name="filters" value="mergeStat" /> -->
<property name="filters" value="stat" />
</bean>
报错信息:
2022-02-21 15:58:58 Commons Daemon procrun stdout initialized
2022-02-21 15:59:06 INFO [org.springframework.web.context.ContextLoader] Root WebApplicationContext: initialization started
2022-02-21 15:59:06 INFO [org.springframework.web.context.support.XmlWebApplicationContext] Refreshing Root WebApplicationContext: startup date [Mon Feb 21 15:59:06 CST 2022]; root of context hierarchy
2022-02-21 15:59:06 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@4665607c: defining beans []; root of factory hierarchy
2022-02-21 15:59:06 INFO [org.springframework.web.context.ContextLoader] Root WebApplicationContext: initialization completed in 297 ms
2022-02-21 15:59:06 INFO [org.apache.axis2.deployment.WarBasedAxisConfigurator] Could not find axis2.xml, loading default org/apache/axis2/deployment/axis2_default.xml from classpath
2022-02-21 15:59:07 INFO [org.apache.axis2.deployment.DeploymentEngine] No services directory was found under C:\tomcat7.0.53\webapps\ROOT\WEB-INF.
2022-02-21 15:59:07 INFO [org.apache.axis2.deployment.DeploymentEngine] No modules directory was found under C:\tomcat7.0.53\webapps\ROOT\WEB-INF.
2022-02-21 15:59:07 WARN [org.apache.axis2.transport.http.AxisServlet] No transportReceiver for org.apache.axis2.transport.http.AxisServletListener found. An instance for HTTP will be configured automatically. Please update your axis2.xml file!
2022-02-21 15:59:07 INFO [org.springframework.web.servlet.DispatcherServlet] FrameworkServlet 'spring': initialization started
2022-02-21 15:59:07 INFO [org.springframework.web.context.support.XmlWebApplicationContext] Refreshing WebApplicationContext for namespace 'spring-servlet': startup date [Mon Feb 21 15:59:07 CST 2022]; parent: Root WebApplicationContext
2022-02-21 15:59:07 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-servlet.xml]
2022-02-21 15:59:07 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] Loading XML bean definitions from class path resource [com/config/applicationContext.xml]
2022-02-21 15:59:10 INFO [com.alibaba.druid.pool.DruidDataSource] {dataSource-1} inited
2022-02-21 15:59:11 ERROR [com.alibaba.druid.pool.DruidDataSource] create connection error
com.microsoft.sqlserver.jdbc.SQLServerException: 用户 'root' 登录失败。 ClientConnectionId:e7638e91-f84f-4687-8258-03b9b57ef57d
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:217)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:279)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:99)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:4346)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3160)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$100(SQLServerConnection.java:43)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3123)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7505)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2445)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1981)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1628)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1459)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:773)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1168)
at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:146)
at com.alibaba.druid.filter.stat.StatFilter.connection_connect(StatFilter.java:211)
at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:140)
at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1328)
at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1382)
at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:1533)
改过配置管理TCP/IP,并重启了sql server服务

用户名和密码能在SSMS上直接sql密码登录,并能看到使用数据库。
