Date: 1 Apr 2004 08:57:42 -0800
Message-ID: <5e092a4e.0404010857.272068f5_at_posting.google.com>
ilee_at_bigpond.net.au (Ivan) wrote in message news:<90137e1b.0403301523.55aed707_at_posting.google.com>...
> Hi all,
>
> I have an application that is written in servlets that connects to an
> oracle database 8.1.7 via jdbc. My DBA has just notify me that I am
> not using bind variables in my code and was wondering what i'll need
> to change to utilise this.
>
> At the moment i am just opening a connection, making a statement (sql
> query) and executing it to return a resultset. Would i need to change
> all my queries to stored procedures so that bind variables are used or
> is there another way.
>
> thanks all
Ivan -
Connection c = new Connection(.... Statement st = c.createStatement(); ResultSet rs = st.executeQuery('select xyz from table1 where a = 2 andb = 3');
you'll want something more like....
PreparedStatement pt = c.prepareStatement('select xyz from table1
where a = ? and b = ?');
pt.setInt(1, 2);
pt.setInt(2, 3);
ResultSet rs = pt.executeQuery();
Dave Received on Thu Apr 01 2004 - 18:57:42 CEST