Recently (6.1 dev, build # >= 516) a new database configuration panel was introduced in the Rails project wizard that lets the user register JDBC connections in the IDE and use existing registered connections. In addition, the wizard now automatically creates a reference to the database driver JAR file(s).
If the database configuration panel is skipped, by default the project will be generated using the MySQL Rails database adapter, i.e. JDBC will not be used even if the selected platform was JRuby.
When not using JRuby and/or JDBC, the user can choose to just specify the Rails adapter or select connections registered in the IDE whose connection information will be used to generate database.yml. The behaviour depends on whether which one of the 'Configure Using IDE Connections' and 'Specify Database Information Directly' radio buttons is selected.
When not using connections registered in the IDE, i.e. when the 'Specify Database Information Directly' radio button is selected, the user can choose a Rails database adapter, specify the name of the database and database user credentials. Database.yml will then be generated according to this information. It is important to note that this configuration applies only to the development database - the test and production database configuration are left as they generated by Rails by default - the IDE doesn't alter the configurations for these in any way.
An alternative way to configure database is to use the connections registered in the IDE - this can be done by selecting the 'Configure Using IDE Connections' radio button.
It is possible to use the connections registered in the IDE and register new connections both with and without JDBC. All three combo boxes contain an item that lets the user to register a new connection. After the user has specified the connection params, the created connection is registered in the IDE. This means that the connection is visible under the Database node in the Services tab and that the DB explorer can be used for browsing the db structure and performing queries. If there are already some registered connections in the IDE, they will be displayed in the combo boxes.
adapter: postgresql host: localhost port: 5432 database: mydatabase .. ( + user and password)
i.e. no suffixes such as _development are added to the database name. The idea is that it should point to an existing database.
If the 'Access Database Using JDBC' check box is checked, the IDE will configure Rails to use JDBC drivers for accessing database. For example for a MySQL JDBC connection the generated entry in database.yml could look like the following:
development:
host: localhost
adapter: jdbc
driver: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/depot_development
username: user
password: pwd
When using JDBC to access the database, the IDE will create references to the driver JAR file(s) of the selected JDBC connections so that the created project is runnable without having to add class path entries to JRuby classpath. The references will be created to project.properties and/or private.properties, depending on whether the driver files could be referenced using a relative path or an absolute path - if the former, the reference will be in both, and if the latter, the reference will be put only to private.properties.
The Create DB buttons next to the JDBC connection combo boxes let you create MySQL databases. After creating a database, the user is prompted for connection parameters and then the connection to the newly created database is preselected in the corresponding combo box.
| db-jdbc.png | ![]() |
26573 bytes |
| db-no-jdbc.png | ![]() |
25950 bytes |