[#46502] Twitterのサンプルでエラーなんですが。 — "T.Soejima" <clev@...2.so-net.ne.jp>
そえじま@勉強中です。
9 messages
2009/11/02
[#46517] Ruby1.8.8devでのsinatra動作について — "前川 映一" <eiichi_maekawa@...>
7 messages
2009/11/05
[#46530] ARGVの引数のデータタイプ — askar <askar75@...>
アスカルです。
9 messages
2009/11/09
[#46532] Re: ARGVの引数のデータタイプ
— Yukihiro Matsumoto <matz@...>
2009/11/09
まつもと ゆきひろです
[#46535] Re: ARGVの引数のデータタイプ
— askar <askar75@...>
2009/11/11
まつもとさん、
[#46546] CSV.openがうまく動きません — ichirojiro <ichirojiro@...>
ichiroと申します。
8 messages
2009/11/14
[#46558] 【追記】 Ruby on Railsセミナーのエントリーについて — 川井健史(CO) <takeshi.kawai@...>
Rubyistの皆様
4 messages
2009/11/15
[#46571] ruby1.9 でpostgresql8.4を利用するときについて。 — Nobuyuki Inaba <nobuyuki.inaba@...>
稲葉と申します。
8 messages
2009/11/27
[#46575] Re: ruby1.9 でpostgresql8.4を利用するときについて。
— keiichi matsunaga <ma2@...>
2009/11/30
On 11/27/2009 7:12 PM, Nobuyuki Inaba wrote:
[#46572] [ANN]12/12 DevLOVE2009Fusion を開催します — <papanda0806@...>
ruby-listのみなさん
1 message
2009/11/27
[ruby-list:46563] DBI実行エラーについて
From:
"前川 映一" <eiichi_maekawa@...>
Date:
2009-11-17 05:11:47 UTC
List:
ruby-list #46563
前川です。
http://code.nanigac.com/source/wiki/view/496
にあるサンプルプログラム(dbi確認用)を実行しましたが、エラーが生じました。
回避策につきまして、ご教示ください。
使用したプログラム
#!D:/Ruby/bin/ruby.exe -Ks
require 'dbi'
begin
dbh = DBI.connect('DBI:Mysql:hellodb', 'root', 'dbkey')
# dbh = DBI.connect('DBI:Mysql:fbsys', 'root', 'dbkey')
sth = dbh.prepare('select * from dept')
puts dbh
puts sth
sth.execute
sth.fetch { |row|
p row
}
sth.finish
#DB例外発生時の処理
rescue DBI::DatabaseError => e
p "An error occurred"
p "Error code: #{e.err}"
p "Error message: #{e.errstr}"
#切断漏れしないようにensureでdisconnectします。
ensure
dbh.disconnect if dbh
end
実施結果
1.3行、2列のデータベースの場合
hellodbのdbkeyのデータ
100,Sales
200,Manage
300,Execute
Rubyのp row の結果
#<DBI::DatabaseHandle:0x2cd67a0> #-> dbh DBI::DatabaseHandleオブジェクト
#<DBI::StatementHandle:0x2cd637c> #-> sth SQL文stmtの実行準備し
て、DBI::StatementHandleを戻す。
[100, 0] #-> Sales が、0 となっている。以下同様。
[200, 0] #->0となった列の定義は、CHAR(50)
[300, 0]
2.55行、31列のデータベースの場合
fbsysのaplistのデータ
以下のSegmentation faultが、発生しました。
D:/Ruby/lib/ruby/site_ruby/1.8/dbd/mysql/statement.rb:130: [BUG]
Segmentation fault
ruby 1.8.7 (2009-06-12 patchlevel 174)
[i386#<DBI::DatabaseHandle:0x2cd67a0>
#<DBI::StatementHandle:0x2cd637c>
-mswin32]
This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information.
3.パラメータのroot,dbkeyを別の値に変えた場合
エラーとなり、例外発生処理が機能していることを確認できました。
以下のとおりです。
"An error occurred"
"Error code: 1045"
"Error message: Access denied for user 'user'@'localhost' (using password:
YES)"
ruby関連バージョンは、以下です。
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\M118543>ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i386-mswin32]
C:\Documents and Settings\M118543>gem list --local
*** LOCAL GEMS ***
actionmailer (2.3.4)
actionpack (2.3.4)
activerecord (2.3.4)
activeresource (2.3.4)
activesupport (2.3.4)
deprecated (2.0.1)
linecache (0.43)
mysql (2.8.1)
rack (1.0.0)
rails (2.3.4)
rake (0.8.7)
ruby-debug-base (0.10.3)
ruby-debug-ide (0.4.5)
sinatra (0.9.4)
sqlite3-ruby (1.2.5)
よろしくお願いします。