I'm thinking it's just as easy to change setStatement to setPreparedStatement. Just
a personal preference (hence the "personally").  I know what Village uses it, I've
checked it out. In fact, we've written something quite similar that also utilizes a
connection architecture which makes the calls even simpler (by abstracting out for
the programmer the connection specification, they don't care about drivers etc.):

NRSql n = new NRSql ("update emp set first_name = ?, last_name=? where emp_id =
?","some_db_id");
n.setString(1,"John");
n.setString(2,"Doe");
n.setString(3,324);
n.execute();
n.killSQL();

or

NRSql n = new NRSql("insert into emp (last_name,first_name,emp_id,dept_id) values
(?,?,emp_seq.nextval,?)","nr");
n.setString(1,"Doe");
n.SetString(2,"John");
n.setString(3,1);
n.execute();
n.killSQL();


NRSql n = new NRSql("select first_name,last_name from emp where dept_id = ? order by
2,1","some_db_id");
n.setString(1,1);
while (n.nextRow()) {
  // loop and do stuff
  htp.println(n.getString("last_name") + ",  " + n.getString("first_name") +
"<BR>");
};
n.killSQL();

It's easy. It's fast. It's intuitive. It works.


As I said, personally, that's maybe more intuitive from a SQL programmer's
perspective than:

TableDataSet tds = new TableDataSet ( connection, "table_name", new
KeyDef().addAttrib("key_column_name"));
Record rec = tds.addRecord();
 rec.setValue ("column_name", "'");
rec.save();
tds.close();


Some tools try to do too much thinking for the developer. Just my opinion.




jon * wrote:

> > Personally, I think there's an easier way that won't cause you to rewrite a
> lot
> > of code.
>
> how would using Village cause you to re-write a lot of code? You don't have
> to use it everywhere...just where you need it.
>
> > Use prepared statements! Then, replace the ? parameters with the values from
> > getParameter(). JDBC will take care of the single-quotes without you having to
> > worry about them.
>
> what do you think that Village uses on the back end? It just makes it
> trivial to implement prepared statements because the syntax is so easy!
>
> -jon

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to