简体   繁体   English

无法通过Apache Tomcat连接到MSSQL DB

[英]Can't connect to MSSQL DB through Apache Tomcat

I'm trying to set up Geoportal 1.2.7 , running on Apache Tomcat 8.5.6 , MSSQL Server 2012, JDK 8, and jdbc 4 . 我正在尝试设置在Apache Tomcat 8.5.6MSSQL Server 2012, JDK 8, and jdbc 4上运行的Geoportal 1.2.7 I can log into the Geoportal, but when I go to the Administration tab, I get the error 我可以登录到Geoportal,但是转到“管理”选项卡时,出现错误

"A database communication error has occurred" “发生数据库通信错误”

Checking the Apache logfiles, I see there's a severe error 检查Apache日志文件,我发现有严重错误

java.sql.SQLException: Cannot create PoolableConnectionFactory (The port number 1433:geoportal is not valid.) java.sql.SQLException:无法创建PoolableConnectionFactory(端口号1433:geoportal无效。)

I have tried a range of different entries in the config for the jdbc, but it always comes back to that error. 我已经在jdbc的配置中尝试了一系列不同的条目,但是它总是返回到该错误。

<Context docBase="geoportal" path="/geoportal" debug="0" reloadable="true" crossContext="true">
    <Resources
         cachingAllowed="true"
         cacheMaxSize="100000"
     />
    <Resource name="jdbc/gpt" auth="Container" type="javax.sql.DataSource"
              driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
              url="jdbc:sqlserver://SQLDEMOSERVER:1433:geoportal"
              user="******"
              password="*******"  
              maxTotal="20"
              maxIdle="10"
              maxWaitMillis="-1" />
</Context>

That is just my latest attempt. 那只是我的最新尝试。 I have seen conflicting posts all over the net about exactly what the url should look like. 我在网上看到有关URL到底是什么样的矛盾文章。

I have tried url="jdbc:sqlserver://SQLDEMOSERVER:1433;databaseName=geoportal" (Geoportal won't launch), url="jdbc:sqlserver://SQLDEMOSERVER:1433/databaseName=geoportal" (Then I get the port error), url="jdbc:sqlserver://SQLDEMOSERVER:1433" (Geoportal won't load). 我已经尝试过url="jdbc:sqlserver://SQLDEMOSERVER:1433;databaseName=geoportal" (Geoportal won't launch), url="jdbc:sqlserver://SQLDEMOSERVER:1433/databaseName=geoportal" (Then I get the port error), url="jdbc:sqlserver://SQLDEMOSERVER:1433" (Geoportal won't load).

I'm at my wits end. 我机智。 I checked the rest of the config files carefully, and the editing within them was minimal and probably has no play on the error. 我仔细检查了其余的配置文件,并且在其中进行的编辑非常少,并且可能对错误没有任何作用。

If anyone could point out my mistake it would be appreciated. 如果有人指出我的错误,将不胜感激。

尝试

url="jdbc:sqlserver://SQLDEMOSERVER:1433/geoportal

These URLs work for me on SQL Server 2012: 这些URL在SQL Server 2012上对我有用:

jdbc:sqlserver://localhost:1433;databaseName=test
jdbc:sqlserver://localhost:1433;database=test

This does not work for me in SQL Server 2012 but might work with older versions: 这不适用于我在SQL Server 2012中,但可能适用于旧版本:

jdbc:sqlserver://localhost:1433/test

These do not work at all: 这些根本不起作用:

jdbc:sqlserver://localhost:1433/databaseName=test
jdbc:sqlserver://localhost:1433:test

I suppose the problem is elsewhere (investigate the "won't launch" problem in more detail). 我认为问题出在其他地方(详细研究“不会启动”问题)。

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

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