|
From: Thomas R. <tri...@tr...> - 2004-02-20 05:05:22
|
I like the new convenience methods we added to JdbcTemplate, but there
is still one missing. I would like to add a simple "void execute(String
sql) method that simply creates a statement and executes the sql. No
return values, prepared statements or parameters, just a plain execute.
It would be nice for something like the following:
JdbcTemplate jt = new JdbcTemplate(dataSource);
jt.execute("drop table spring_test");
jt.execute("create table spring_test (id integer, name
varchar(100))");
jt.update("insert into spring_test (id, name) values (?, ?)",
new Object[] {new Integer(1), "Marc"});
jt.update("insert into spring_test (id, name) values (?, ?)",
new Object[] {new Integer(2), "Bill"});
List l = jt.queryForList("select * from spring_test");
System.out.println(l);
I could use an update(sql) for the DDL statements, but they are not
update statements, so I would prefer the execute name and also bypassing
the prepared statement - no reason to prepare a statement for a one off
statement without bind variables.
The only problem is that we have another execute method that is used by
the StoredProcedure for running a CallableStatement. We could rename
that one to call() or executeCall(). I don't think anybody is using
this method directly, so the impact on existing code would be low.
What do you all think?
Thomas
|