5 ms·
Also worth adding to the list are Querulous and Configgy, which are (respectively) a database abstraction layer which is optimised for running raw SQL (it's not
by frio 16y ago
Also worth adding to the list are Querulous and Configgy, which are (respectively) a database abstraction layer which is optimised for running raw SQL (it's not an ORM, it just abstracts away 90% of the JDBC bullshit), and a config/logging library.
Also, sbt is fantastic. sbt ~test is a cheap form of CI: every time you save a file, your project gets recompiled and your tests re-run; it makes it really easy to get IDE-like error detection out of a simple text editor, and encourages you to write tests for your code.
- Stormbringer 16y agoWhat's wrong with JDBC? Slap a driver in, and then populate the parameters of your statement (basically a query string wrapped in an object that prevents SQL injection attacks) and BAM you're good to go. Iterate through the result set. If you want fast raw (but no food poisoning) SQL it doesn't get much better than that. I hope your Querulous and Configgy are set up in such a way as to easily avoid SQL Injection? Or since you're talking about database abstraction, at the other end of the scale JPA is an absolute dream. Very easy to get up and running fast with the right tools (Netbeans used to be good for this). Just don't touch J2EE with a barge-pole (Java EE 5 is the nice one) and you'll be fine.
- frio 16y agoI find JDBC unnecessarily wordy for everyday usage. Preventing SQL injection with: PreparedStatement x = dbh.prepare("SELECT * FROM mytable WHERE a = ? AND b = ?"); x.setString(1, "test"); x.setInt(2, 3); ResultSet xs = x.execute() while (x.next()) { ... } ... and so on and so forth, is far more lines than I personally think I should need to write. The type system already knows the types of the vars I'm dealing with: why should I have to retell it what they are? Querulous: val connection = QueryEvaluator(host, dbname, username password); connection.select("SELECT * FROM mytable WHERE a = ? AND b = ?", "test", 3) { row => ... } It's much more concise, it's just as type-safe (and therefore avoids SQL Injection, as behind the scenes Querulous uses a prepared statement), and (to my mind) makes code much easier to deal with. Each to their own :), but after dealing with a _lot_ of raw JDBC in another project, Querulous has been much nicer to me.