Friday, September 11, 2009

SQLite for Netbeans

I’m using Netbeans for all my projects, since it does integrate so nice with Ruby/Webrick/GlassFish/Mongrel for Ruby on Rails application development. And I have a MySQL database server running locally for testing applications. But, sometimes I need something really fast, like testing an app with SQLite support. And I haven’t been able to find a plugin for Netbeans that would add SQLite database support.
So, here’s how I did it. First, go to the SQLiteJDBC project page or mirror, and download the latest .jar file. Move the file into the Netbeans extensions folder, which, in my case was C:\Program Files\NetBeans\ide10\modules\ext.
Now, to add the driver into Netbeans. Fire up the IDE, click on the Services tab, right click on Drivers and select New Driver. On the newly-opened window, press Add and browse to your .jar file. Your SQLiteJDBC .jar file, of course. Click on Find and Netbeans should detect the driver class inside as org.sqlite.JDBC. Enter a name for the driver, for example, SQLite.
Let’s test the module if it does work. Click on Services tab, right click on Databases, select New Connection. Choose the SQLite driver in the Name select box, leave the username and password fields empty and enter the JDBC URL.
The JDBC URL is in the format jdbc:driver://path/to/database.
For example:
jdbc:sqlite://c:/my_test_db.db
Click OK, click OK again and the new database connection should appear into the Services list. Now you can configure your Rails application to use that database.

No comments: