應用JDBC連線SQLite

whz110發表於2008-09-01

用"SQLite.JDBCDriver"作為JDBC的驅動程式類名。連線JDBC的URL格式為jdbc:sqlite:/path。這裡的path為指定到SQLite資料庫檔案的路徑,例如:
jdbc:sqlite://dirA/dirB/dbfile
jdbc:sqlite://DRIVE:/dirA/dirB/dbfile
jdbc:sqlite://COMPUTERNAME/shareA/dirB/dbfile

 

設定environment.rb:

if RUBY_PLATFORM =~ /java/
  require 'rubygems'
  gem 'activerecord-jdbcsqlite3-adapter'
  #require 'active_record/connection_adapters/jdbcsqlite3_adapter'
  require 'jdbc_adapter' 
end
 

設定database.yml:

#SQLite3
development:
  adapter: jdbcsqlite3
  url: jdbc:sqlite:db/test.db 
  
production:
  adapter: jdbcsqlite3
  url: jdbc:sqlite:db/test.db 
 

 

相關文章