3 ms·
I find JDBC unnecessarily wordy for everyday usage. Preventing SQL injection with: PreparedStatement x = dbh.prepare("SELECT * FROM mytable WHERE a = ? AND b
by frio 16y ago
I 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.