我正在使用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.testConnectionOnCheckout和c3p0.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) 如何为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) 如何在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
如果是这样,它们有多么不同可能?
如果没有,为什么两者都存在?为什么不拥有一个没有另一个?如果您没有:timeoutable,则自动记住会话.如果您没有:可记住,则会话自动超时.
http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Rememberable
http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable
为什么要复制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) 我有一个现有的数据库。我创建了两个迁移
$ 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) 从VBA(Access)执行以下行时,我遇到以下错误:
Set wd = CreateObject("Word.Application")
Run Code Online (Sandbox Code Playgroud)

我找到了以下链接,但没有发现它有用:http://support.microsoft.com/kb/828550
Dim wd As Object而不是Dim wd as Word.Applicationwinword.exe /RegServer在管理员命令提示符下运行 没有默默地运行,只是打开了Word.winword.exe /automation.仅仅启动Word.winword.exe以管理员身份运行access.exe以管理员身份运行如何从控制器中获取当前操作?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) 我将这些方法设置为自动加密值.
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) 当我将 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: …