Module: RTM::Ontopia::Rdbms::Properties::DatabaseDefaults
- Extended by:
- DatabaseDefaults
- Included in:
- DatabaseDefaults
- Defined in:
- lib/rtm/ontopia/rdbms/properties.rb
Overview
The defaults for database connections here were extracted from the *_connection methods from activerecord-jdbc-adapter-0.9.2. They had to be copied here because we don’t want to establish connections here. The definitions where slightly extended, e.g. the host is optional and defaults to localhost.
Instance Method Summary collapse
-
#cachedb_config(config) ⇒ Object
enhances a config hash using the defaults for cachedb.
-
#db2_config(config) ⇒ Object
enhances a config hash using the defaults for db2.
-
#derby_config(config) ⇒ Object
enhances a config hash using the defaults for derby.
-
#h2_config(config) ⇒ Object
enhances a config hash using the defaults for h2.
-
#hsqldb_config(config) ⇒ Object
enhances a config hash using the defaults for hsqldb.
-
#informix_config(config) ⇒ Object
enhances a config hash using the defaults for informix.
-
#mssql_config(config) ⇒ Object
(also: #sqlserver_config)
enhances a config hash using the defaults for mysql.
-
#mysql_config(config) ⇒ Object
enhances a config hash using the defaults for mysql.
-
#oracle_config(config) ⇒ Object
(also: #oracle8_config, #oracle9i_config, #oracle10g_config)
enhances a config hash using the defaults for oracle.
-
#postgresql_config(config) ⇒ Object
enhances a config hash using the defaults for postgresql.
-
#sqlite3_config(config) ⇒ Object
enhances a config hash using the defaults for sqlite3.
Instance Method Details
#cachedb_config(config) ⇒ Object
enhances a config hash using the defaults for cachedb
33 34 35 36 37 38 39 |
# File 'lib/rtm/ontopia/rdbms/properties.rb', line 33 def cachedb_config(config) config[:host] ||= "localhost" config[:port] ||= 1972 config[:url] ||= "jdbc:Cache://#{config[:host]}:#{config[:port]}/#{config[:database]}" config[:driver] ||= "com.intersys.jdbc.CacheDriver" config end |
#db2_config(config) ⇒ Object
enhances a config hash using the defaults for db2
42 43 44 45 46 47 |
# File 'lib/rtm/ontopia/rdbms/properties.rb', line 42 def db2_config(config) config[:adapter] ||= "jdbc" config[:driver] ||= "com.ibm.db2.jcc.DB2Driver" config[:url] ||= "jdbc:db2:#{config[:database]}" config end |
#derby_config(config) ⇒ Object
enhances a config hash using the defaults for derby
50 51 52 53 54 |
# File 'lib/rtm/ontopia/rdbms/properties.rb', line 50 def derby_config(config) config[:url] ||= "jdbc:derby:#{config[:database]};create=true" config[:driver] ||= "org.apache.derby.jdbc.EmbeddedDriver" config end |
#h2_config(config) ⇒ Object
enhances a config hash using the defaults for h2
65 66 67 68 69 70 |
# File 'lib/rtm/ontopia/rdbms/properties.rb', line 65 def h2_config(config) config[:url] ||= "jdbc:h2:#{config[:database]};MVCC=true" config[:url] << config[:h2_params] if config[:h2_params] config[:driver] ||= "org.h2.Driver" config end |
#hsqldb_config(config) ⇒ Object
enhances a config hash using the defaults for hsqldb
57 58 59 60 61 62 |
# File 'lib/rtm/ontopia/rdbms/properties.rb', line 57 def hsqldb_config(config) # config[:url] ||= "jdbc:hsqldb:#{config[:database]}" # ActiveRecord JDBC default config[:url] ||= "jdbc:hsqldb:#{config[:database]};MVCC=true" # Ontopia default config[:driver] ||= "org.hsqldb.jdbcDriver" config end |
#informix_config(config) ⇒ Object
enhances a config hash using the defaults for informix
73 74 75 76 77 78 79 80 |
# File 'lib/rtm/ontopia/rdbms/properties.rb', line 73 def informix_config(config) config[:host] ||= "localhost" config[:servername] ||= config[:host] config[:port] ||= 9088 config[:url] ||= "jdbc:informix-sqli://#{config[:host]}:#{config[:port]}/#{config[:database]}:INFORMIXSERVER=#{config[:servername]}" config[:driver] = 'com.informix.jdbc.IfxDriver' config end |
#mssql_config(config) ⇒ Object Also known as: sqlserver_config
enhances a config hash using the defaults for mysql
83 84 85 86 87 88 89 |
# File 'lib/rtm/ontopia/rdbms/properties.rb', line 83 def mssql_config(config) config[:host] ||= "localhost" config[:adapter] ||= "jdbc" # Ontopia example: sqlserver config[:url] ||= "jdbc:jtds:sqlserver://localhost:1433/weblog_development" # Ontopia example: jdbcspy:jdbc:sqlserver://127.0.0.1\\ONTOPIA;databaseName=topicmaps;lockTimeout=60000 config[:driver] ||= 'net.sourceforge.jtds.jdbc.Driver' # Ontopia example: com.microsoft.sqlserver.jdbc.SQLServerDriver config end |
#mysql_config(config) ⇒ Object
enhances a config hash using the defaults for mysql
93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/rtm/ontopia/rdbms/properties.rb', line 93 def mysql_config(config) config[:host] ||= "localhost" config[:port] ||= 3306 config[:encoding] ||= 'utf8' = "zeroDateTimeBehavior=convertToNull&jdbcCompliantTruncation=false&useUnicode=true&characterEncoding=#{config[:encoding]}" if config[:url] config[:url] = config[:url]['?'] ? "#{config[:url]}&#{}" : "#{config[:url]}?#{}" else config[:url] = "jdbc:mysql://#{config[:host]}:#{config[:port]}/#{config[:database]}?#{}" end config[:driver] = "com.mysql.jdbc.Driver" config end |
#oracle_config(config) ⇒ Object Also known as: oracle8_config, oracle9i_config, oracle10g_config
enhances a config hash using the defaults for oracle
108 109 110 111 112 113 114 |
# File 'lib/rtm/ontopia/rdbms/properties.rb', line 108 def oracle_config(config) config[:host] ||= "localhost" config[:port] ||= 1521 config[:url] ||= "jdbc:oracle:thin:@#{config[:host]}:#{config[:port]}:#{config[:database]}" config[:driver] ||= "oracle.jdbc.driver.OracleDriver" config end |
#postgresql_config(config) ⇒ Object
enhances a config hash using the defaults for postgresql
120 121 122 123 124 125 126 127 |
# File 'lib/rtm/ontopia/rdbms/properties.rb', line 120 def postgresql_config(config) config[:host] ||= "localhost" config[:port] ||= 5432 config[:url] ||= "jdbc:postgresql://#{config[:host]}:#{config[:port]}/#{config[:database]}" config[:url] << config[:pg_params] if config[:pg_params] config[:driver] ||= "org.postgresql.Driver" config end |
#sqlite3_config(config) ⇒ Object
enhances a config hash using the defaults for sqlite3
130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/rtm/ontopia/rdbms/properties.rb', line 130 def sqlite3_config(config) config[:database] ||= config[:dbfile] # Allow database path relative to RAILS_ROOT, but only if # the database path is not the special path that tells # Sqlite to build a database only in memory. if Object.const_defined?(:RAILS_ROOT) && ':memory:' != config[:database] config[:database] = File.(config[:database], RAILS_ROOT) end config[:url] ||= "jdbc:sqlite:#{config[:database]}" config[:driver] ||= "org.sqlite.JDBC" config end |