0

我正在尝试使用 mssql 服务器数据库初始化声纳,但我不能。使用 Microsoft SQL Server Management Studio,我使用用户名“sonar”和密码“sonar”创建了用户,并授予了同样创建的“sonar”数据库的所有正确权限。还将“服务器身份验证”配置为“SQL Server 和 Windows 身份验证模式”。它运行良好,但我无法使用声纳连接到数据库。谢谢,

声纳属性;

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

日志;

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
4

1 回答 1

1

很明显sonar无法连接到SQL Server

发生这种情况的原因可能有很多

  • 服务器名称拼写错误或端口号不正确。
  • SQL Server 未配置为使用 TCP/IP。从 SQL Server 的网络实用程序应用程序启用 TCP/IP 或让 jTDS 通过命名管道连接(有关如何执行此操作的信息,请参阅 URL 格式)。
  • 服务器上有防火墙阻止了 1433 端口。

要检查是否启用了 TCP/IP 并且端口没有被阻止,您可以使用“telnet 1433”。在 telnet 没有连接之前,jTDS 也不会。如果您不知道原因,请向您的网络管理员寻求帮助

总结:在使用 SQL Server 设置 Sonar 时,使用 Java SQL 客户端(如 Squirrel SQL)测试连接并尝试各种连接方式非常有帮助。这样,您就知道是否有问题要怪 Sonar .

于 2012-11-03T13:18:16.123 回答