小编Chl*_*loe的帖子

MSSQL JDBC驱动程序在第一次连接时不会连接到镜像failoverPartner

我正在使用C3P0和MS SQL JDBC 4驱动程序在数据库消失时自动故障转移到新的数据库镜像.如果它首先连接到主体数据库,则故障转移将起作用,并且无缝切换到镜像数据库.但是,如果主应用程序在应用程序启动时关闭,并且镜像数据库可用于连接(使用MSSQL Studio进行测试),则应用程序无法启动并无法连接到备份镜像.

这是连接URL:

jdbc:sqlserver://PRINCIPALDB;databaseName=app_space;port=99999;failoverPartner=MIRRORDB
Run Code Online (Sandbox Code Playgroud)

我有c3p0.testConnectionOnCheckoutc3p0.preferredTestQuery设置,并c3p0.acquireRetryAttempts没有设置(使用默认值30).

当主体关闭时,为什么它最初不会连接到镜像DB?我们需要这个,因为如果电源关闭或主要数据库关闭,并且应用服务器需要回收,那么故障转移将无济于事.

参考:

http://www.mchange.com/projects/c3p0/#configuring_recovery

使用数据库镜像(JDBC)(MSDN在其URL中使用未转义的括号!)http://msdn.microsoft.com/en-US/library/aa342332 (v=sql.90 )


以下是该应用的一些日志.

<14>[APP]: INFO 20 Jul 2012 12:21:21,982 [main] net.sf.hibernate.connection.C3P0ConnectionProvider "C3P0 using driver: com.microsoft.sqlserver.jdbc.SQLServerDriver at URL: jdbc:sqlserver://PRINCIPAL;databaseName=APP_space;port=9999;failoverPartner=MIRRORDB"    
<14>[APP]: INFO 20 Jul 2012 12:21:21,982 [main] net.sf.hibernate.connection.C3P0ConnectionProvider "Connection properties: {user=USERNAME, password=PASSWORD}"    
<14>[APP]: INFO 20 Jul 2012 12:21:22,435 [main] net.sf.hibernate.transaction.TransactionFactoryFactory "Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory"
<14>[APP]: INFO 20 Jul 2012 12:21:22,450 [main] net.sf.hibernate.transaction.TransactionManagerLookupFactory "No TransactionManagerLookup configured (in JTA environment, use of process level read-write …
Run Code Online (Sandbox Code Playgroud)

sql-server jdbc c3p0

8
推荐指数
2
解决办法
1万
查看次数

如何在Windows上安装rmagick gem?

如何为Windows XP安装rmagick gem?我已经使用头文件安装了ImageMagick,并安装了DevKit附带的RailsInstaller.org.我不知道在哪里修复这些错误.

C:\RailsInstaller\ImageMagick-6.8.2-Q16>ruby -v
ruby 1.9.3p125 (2012-02-16) [i386-mingw32]

C:\RailsInstaller\ImageMagick-6.8.2-Q16>gem -v
1.8.16

C:\RailsInstaller\ImageMagick-6.8.2-Q16>path=%PATH%;C:\RailsInstaller\ImageMagick-6.8.2-Q16

C:\RailsInstaller\ImageMagick-6.8.2-Q16>identify
Version: ImageMagick 6.8.2-0 2013-01-24 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC

C:\RailsInstaller\ImageMagick-6.8.2-Q16>gem install rmagick
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.
        C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb
checking for Ruby version >= 1.8.5... yes
Invalid drive specification.
Unable to get ImageMagick version
*** extconf.rb failed ***
Could not create Makefile …
Run Code Online (Sandbox Code Playgroud)

ruby gem rubygems rmagick imagemagick

8
推荐指数
1
解决办法
1万
查看次数

如何在Yii中转储变量以进行调试?

如何在Yii中转储和打印变量以进行调试?我想用var_dump()print_r().我尝试使用Yii::trace()但它崩溃了这个错误runtime/logs/app.log.它甚至没有告诉我代码中的行失败.

2015-03-18 20:54:11 [::1][-][-][warning][yii\log\Dispatcher::dispatch] Unable to send log via yii\debug\LogTarget: Exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed'

in /cygdrive/c/Users/Chloe/workspace/AffiliateArbitrage/vendor/yiisoft/yii2-debug/LogTarget.php:58

Stack trace:
#0 /cygdrive/c/Users/Chloe/workspace/AffiliateArbitrage/vendor/yiisoft/yii2-debug/LogTarget.php(58): serialize(Array)
#1 /cygdrive/c/Users/Chloe/workspace/AffiliateArbitrage/vendor/yiisoft/yii2-debug/LogTarget.php(112): yii\debug\LogTarget->export(Array)
#2 /cygdrive/c/Users/Chloe/workspace/AffiliateArbitrage/vendor/yiisoft/yii2/log/Dispatcher.php(183): yii\debug\LogTarget->collect(Array, true)
#3 /cygdrive/c/Users/Chloe/workspace/AffiliateArbitrage/vendor/yiisoft/yii2/log/Logger.php(170): yii\log\Dispatcher->dispatch(Array, true)
#4 [internal function]: yii\log\Logger->flush(true)
#5 {main}
Run Code Online (Sandbox Code Playgroud)

参考 http://www.yiiframework.com/doc-2.0/guide-runtime-logging.html

php yii yii2

8
推荐指数
1
解决办法
2万
查看次数

你可以使用Devise:timeoutable和:同时记得吗?

如果是这样,它们有多么不同可能?

如果没有,为什么两者都存在?为什么不拥有一个没有另一个?如果您没有:timeoutable,则自动记住会话.如果您没有:可记住,则会话自动超时.

http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Rememberable

http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable

ruby-on-rails devise

8
推荐指数
1
解决办法
677
查看次数

为什么要将 Gemfile.lock 复制到 Docker 中,然后立即覆盖它?

为什么要复制Gemfile.lock,运行bundle install以创建一个新的Gemfile.lock,然后立即复制包含原始目录的当前目录Gemfile.lock并覆盖Gemfile.lock刚刚由 Bundler 在 Docker 容器中创建的目录?

还有为什么你可以摆脱没有EXPOSE 3000

https://docs.docker.com/compose/rails/#define-the-project

FROM ruby:2.3.3
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
COPY . /myapp
Run Code Online (Sandbox Code Playgroud)

这不是唯一这样做的地方。它也在这里完成,这似乎很官方。也许我错过了 Docker 的一个基本方面?

https://hub.docker.com/_/ruby/

COPY Gemfile Gemfile.lock ./
RUN bundle install

COPY . .
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails bundler docker

8
推荐指数
2
解决办法
1026
查看次数

如何让 FlyWay 运行我的迁移?“架构是最新的。无需迁移。”

我有一个现有的数据库。我创建了两个迁移

$ ls src/main/resources/db/migration/
V1__create_stats.sql  V2__create_sources.sql
Run Code Online (Sandbox Code Playgroud)

我设置了以下内容 application.properties

# Prevent complaints when starting migrations with existing tables.
flyway.baselineOnMigrate = true
Run Code Online (Sandbox Code Playgroud)

否则它会给出错误org.flywaydb.core.api.FlywayException: Found non-empty schemagalaxybadgewithout metadata table! Use baseline() or set baselineOnMigrate to true to initialize the metadata table.

当我尝试启动应用程序时,它会跳过迁移并且不执行它们!我show tables;在 MySQL 中使用,看到它们不在那里!

>mvn spring-boot:run
...
2018-05-09 18:43:03.671  INFO 24520 --- [  restartedMain] o.f.core.internal.util.VersionPrinter    : Flyway 3.2.1 by Boxfuse
2018-05-09 18:43:04.420  INFO 24520 --- [  restartedMain] o.f.c.i.dbsupport.DbSupportFactory       : Database: jdbc:mysql://localhost:3306/galaxybadge (MySQL 5.5)
2018-05-09 18:43:04.486  INFO 24520 …
Run Code Online (Sandbox Code Playgroud)

java flyway spring-boot

8
推荐指数
1
解决办法
5414
查看次数

运行时错误429,ActiveX组件无法创建对象,自动化MS Word应用程序,CreateObject("Word.Application")

从VBA(Access)执行以下行时,我遇到以下错误:

Set wd = CreateObject("Word.Application")
Run Code Online (Sandbox Code Playgroud)

Imgur

我找到了以下链接,但没有发现它有用:http://support.microsoft.com/kb/828550

我试过的事情


  • 从"控制面板">"程序和功能"修复Office的安装
  • 卸载MS Word,重新安装
  • 尝试Dim wd As Object而不是Dim wd as Word.Application
  • 手动运行Word.
  • winword.exe /RegServer在管理员命令提示符下运行 没有默默地运行,只是打开了Word.
  • 检查CLSID {000209FF-0000-0000-C000-000000000046}下的LocalServer32密钥.最初失踪了.重新安装Word后,CLDID就在那里但缺少LocalServer32密钥.
  • winword.exe /automation.仅仅启动Word.
  • winword.exe以管理员身份运行
  • access.exe以管理员身份运行

相关(也许)


  • Windows 8 x64
  • Office 2007
  • C:\ Program Files(x86)\ Microsoft Office\Office12
  • 预安装了Office 2010的预览版.
  • 启动Excel适用于自动化和VBA.
  • asycfilt.dll文件版本:6.2.9200.16384,日期:7/25/2012 11:05 pm
  • oleaut32.dll文件版本:6.2.9200.16384,日期:2012/7/25 11:06
  • olepro32.dll缺失
  • stdole2.tlb没有文件版本,日期:7/25/2012 10:34 pm
  • McAffee抗病毒

vba ole ms-word word-vba windows-8

7
推荐指数
1
解决办法
1万
查看次数

如何从控制器中获取当前操作?

如何从控制器中获取当前操作?current_page?适用于视图,但不适用于控制器.

redirect_to step3_users_path unless current_page?(step3_users_path)
Run Code Online (Sandbox Code Playgroud)

我也试过了

controller.action_name == 'step3'
Run Code Online (Sandbox Code Playgroud)

我也试过了

params[:action_name] == 'step3'
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails ruby-on-rails-4

7
推荐指数
1
解决办法
8036
查看次数

`form_for`绕过了模型访问器.怎么让它停下来?(或者:如何制作自定义属性序列化器?)

我将这些方法设置为自动加密值.

class User < ApplicationRecord
  def name=(val)
    super val.encrypt
  end
  def name
    (super() || '').decrypt
  end
Run Code Online (Sandbox Code Playgroud)

当我尝试提交表单并且出现错误(缺少电话)时,该name属性显示为乱码.

<input class="form-control" type="text" value="Mg8IS1LB2A1efAeZJxIDJMSroKcq6WueyY4ZiUX+hfI=" name="user[name]" id="user_name">
Run Code Online (Sandbox Code Playgroud)

它在验证成功时起作用.当我逐行通过我的控制器时,它也可以在控制台中工作#update.

irb(main):015:0> u = User.find 1
irb(main):016:0> u.name
=> "Sue D. Nym"
irb(main):017:0> u.phone
=> "212-555-1234"
irb(main):018:0> u.update name: 'Sue D. Nym', phone: ''
   (10.0ms)  BEGIN
   (1.0ms)  ROLLBACK
=> false
irb(main):020:0> u.save
=> false
irb(main):029:0> u.errors.full_messages.join ','
=> "Phone can't be blank"
irb(main):031:0> u.build_image unless u.image
=> nil
irb(main):033:0> u.name
=> "Sue D. …
Run Code Online (Sandbox Code Playgroud)

activerecord ruby-on-rails ruby-on-rails-5

7
推荐指数
1
解决办法
195
查看次数

Rails 2.4 =&gt; 3.0:ActiveRecord:`add_modifier`:参数数量错误(给定 3,预期 2)(ArgumentError)

当我将 Ruby 版本从 2.4.3 更新到 3.0.2 ( bundle update) 并尝试运行 Rails 控制台时,收到此错误消息。我该如何解决这个问题?

C:\Users\Chloe\workspace\catalyst_research>rails console
C:/ruby30/lib/ruby/gems/3.0.0/gems/activerecord-5.0.7.2/lib/active_record/type/adapter_specific_registry.rb:7:in `add_modifier': wrong number of arguments (given 3, expected 2) (ArgumentError)
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/activerecord-5.0.7.2/lib/active_record/type.rb:22:in `add_modifier'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/activerecord-5.0.7.2/lib/active_record/connection_adapters/postgresql_adapter.rb:827:in `<class:PostgreSQLAdapter>'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/activerecord-5.0.7.2/lib/active_record/connection_adapters/postgresql_adapter.rb:69:in `<module:ConnectionAdapters>'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/activerecord-5.0.7.2/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `<module:ActiveRecord>'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/activerecord-5.0.7.2/lib/active_record/connection_adapters/postgresql_adapter.rb:19:in `<main>'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/activesupport-5.0.7.2/lib/active_support/dependencies.rb:293:in `block in require'
...
C:/Users/Chloe/workspace/catalyst_research/config/environment.rb:5:in
...
Run Code Online (Sandbox Code Playgroud)

Gemfile

ruby '~>2.4.1'#'~>3.0.2'
gem 'rails', '~> 5.0.2'
...
Run Code Online (Sandbox Code Playgroud)

environment.rb:5:

Rails.application.initialize!
Run Code Online (Sandbox Code Playgroud)

adapter_specific_registry.rb:7: …

ruby ruby-on-rails rails-activerecord

7
推荐指数
1
解决办法
4533
查看次数