Sonar + MS SQL database

安稳与你 提交于 2019-12-23 04:33:15

问题


I'm attempting to initialize sonar with mssql server database, but I can't. With Microsoft SQL Server Management Studio I created the user with username "sonar" and password "sonar" and granted all the correct privileges to "sonar" database, also created. Also configured "Server Authentication" to "SQL Server and Windows Authentication mode".It works perfectly, but I can't have connection to the database with sonar. Thanks,

sonar.properties;

#----- Credentials
# Permissions to create tables and indexes must be granted to JDBC user.
# The schema must be created first.
sonar.jdbc.username:                       sonar
sonar.jdbc.password:                       sonar

#----- Microsoft SQLServer
# The Jtds open source driver is available in extensions/jdbc-driver/mssql. More details on     http://jtds.sourceforge.net
sonar.jdbc.url:jdbc:sqlserver://localhost:1433;databaseName=SONAR;instanceName=r2;selectMethod=cursor
sonar.jdbc.driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
sonar.jdbc.validationQuery: select 1
sonar.jdbc.dialect: mssql

# Optional properties
#sonar.jdbc.driverClassName:                net.sourceforge.jtds.jdbc.Driver

#----- Connection pool settings
sonar.jdbc.maxActive:                      20
sonar.jdbc.maxIdle:                        5
sonar.jdbc.minIdle:                        2
sonar.jdbc.maxWait:                        5000
sonar.jdbc.minEvictableIdleTimeMillis:     600000
sonar.jdbc.timeBetweenEvictionRunsMillis:  30000
...

Logs;

INFO   | jvm 1    | 2012/11/02 15:45:31 | JRuby limited openssl loaded. http://jruby.org/openssl
INFO   | jvm 1    | 2012/11/02 15:45:31 | gem install jruby-openssl for full support.
INFO   | jvm 1    | 2012/11/02 15:46:31 | 2012-11-02 15:46:31.368:WARN:/:unable to create shared     application instance
INFO   | jvm 1    | 2012/11/02 15:46:31 | org.jruby.rack.RackInitializationException: no connection available|?from C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-    INF/vendor/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/connection.rb:61:in `initialize'|?from C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/vendor/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/adapter.rb:31:in `initialize'|?from C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/vendor/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/connection_methods.rb:6:in `jdbc_connection'|?from org/jruby/RubyKernel.java:2056:in `send'|?from C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `new_connection'|?from C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in `checkout_new_connection'|?from C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:in `checkout'|?from org/jruby/RubyKernel.java:1418:in `loop'|?from C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `checkout'|?from file:/C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/lib/jruby-complete-1.6.1.jar!/META-INF/jruby.home/lib/ruby/1.8/monitor.rb:191:in `mon_synchronize'|?from C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:in `checkout'|?from C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:98:in `connection'|?from C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in `retrieve_connection'|?from C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in `retrieve_connection'|?from C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in `connection'|?from C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/vendor/rails/activerecord/lib/active_record/migration.rb:435:in `initialize'|?from C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/vendor/rails/activerecord/lib/active_record/migration.rb:400:in `up'|?from C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/vendor/rails/activerecord/lib/active_record/migration.rb:383:in `migrate'|?from C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/config/../lib/database_version.rb:63:in `upgrade_and_start'|?from C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/config/../lib/database_version.rb:75:in `automatic_setup'|?from C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/config/environment.rb:131:in `(root)'|?from org/jruby/RubyKernel.java:1063:in `load'|?from C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/config/environment.rb:53:in `load_environment'|?from file:/C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/lib/jruby-rack-1.0.0.1.jar!/jruby/rack/rails.rb:46:in `to_app'|?from file:/C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/lib/jruby-rack-1.0.0.1.jar!/jruby/rack/rails.rb:191:in `new'|?from <script>:2:in `(root)'|?from org/jruby/RubyKernel.java:2021:in `instance_eval'|?from file:/C:/Users/eazakli/Desktop/sonar-3.2/sonar-3.2/war/sonar-server/WEB-INF/lib/jruby-rack-1.0.0.1.jar!/vendor/rack-1.2.1/rack/builder.rb:46:in `initialize'|?from <script>:2:in `(root)'|
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.jruby.rack.DefaultRackApplicationFactory$4.init(DefaultRackApplicationFactory.java:184)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.jruby.rack.DefaultRackApplicationFactory.getApplication(DefaultRackApplicationFactory.java:59)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.jruby.rack.SharedRackApplicationFactory.init(SharedRackApplicationFactory.java:27)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.jruby.rack.RackServletContextListener.contextInitialized(RackServletContextListener.java:40)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1272)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:489)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.mortbay.jetty.Server.doStart(Server.java:224)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.sonar.application.JettyEmbedder.start(JettyEmbedder.java:72)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.sonar.application.StartServer.main(StartServer.java:48)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at java.lang.reflect.Method.invoke(Unknown Source)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.tanukisoftware.wrapper.WrapperSimpleApp.run    (WrapperSimpleApp.java:240)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at java.lang.Thread.run(Unknown Source)
INFO   | jvm 1    | 2012/11/02 15:46:31 | 2012-11-02 15:46:31.381:WARN:/:Error: application initialization failed
INFO   | jvm 1    | 2012/11/02 15:46:31 | org.jruby.rack.RackInitializationException: unable to create shared application instance
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.jruby.rack.SharedRackApplicationFactory.init(SharedRackApplicationFactory.java:39)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.jruby.rack.RackServletContextListener.contextInitialized(RackServletContextListener.java:40)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1272)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:489)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.mortbay.jetty.Server.doStart(Server.java:224)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.sonar.application.JettyEmbedder.start(JettyEmbedder.java:72)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.sonar.application.StartServer.main(StartServer.java:48)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at java.lang.reflect.Method.invoke(Unknown Source)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
INFO   | jvm 1    | 2012/11/02 15:46:31 |   at java.lang.Thread.run(Unknown Source)
INFO   | jvm 1    | 2012/11/02 15:46:31 | 2012-11-02 15:46:31.434:INFO::Started     SelectChannelConnector@127.0.0.1:9000

回答1:


It is obvious that sonar cannot connect to SQL Server

There may be a number of reasons why this could happen

  • The server name is misspelled or the port number is incorrect.
  • SQL Server is not configured to use TCP/IP. Either enable TCP/IP from SQL Server's Network Utility app or have jTDS connect via named pipes (see the URL format for information on how to do this).
  • There is a firewall blocking port 1433 on the server.

To check whether TCP/IP is enabled and the port is not blocked you can use "telnet 1433". Until telnet doesn't connect, jTDS won't either. If you can't figure out why, ask your network administrator for help

A general remark: when setting up Sonar with SQL Server, it's very helpful to use a Java SQL client (like Squirrel SQL) to test the connection and experiment with various ways to connect.That way, you know whether to blame Sonar for any problems.



来源:https://stackoverflow.com/questions/13208124/sonar-ms-sql-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!