简体   繁体   中英

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 . I can log into the Geoportal, but when I go to the Administration tab, I get the error

"A database communication error has occurred"

Checking the Apache logfiles, I see there's a severe error

java.sql.SQLException: Cannot create PoolableConnectionFactory (The port number 1433:geoportal is not valid.)

I have tried a range of different entries in the config for the jdbc, but it always comes back to that error.

<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.

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).

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:

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:

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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