4 ms·
What'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 i
by Stormbringer 16y ago
What'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.