Nothing is so good as it seems beforehand.
~ George Eliot (born: 1819-11-22 died: 1880-12-22 at age: 61) (Mary Ann Evans)
During the lifetime of one Connection you can and should use
PreparedStatements.
But of course, you can not save the PreparedStatement e.g. into a
Servlet state for use in later invocations with another Connection.
But one Connection is just an ordinary JDBC Connection. It can do what a
Connection can do.
--
You're at the end of the road again.
No.
--
Lew
No.
Connection pooling gives much better performance because connection
to the database is very costly.
Prepared statement will always protect both against Scottish names
and malicious SQL injection.
To still get the performance benefits from prepared statement, then
your connection pool software needs to be smart enough to keep
the existing prepared statements around together with the connections.
Smart connection pool software do exist !
Arne
Yes. WebLogic's pooling is an example of transparently
pooling PreparedStatements (a configurable number)
along with the connection, repeated use-patterns re-use
the same statements indefinitely.
Joe Weinstein at Oracle
>
>Prepared statement will always protect both against Scottish names
>and malicious SQL injection.
what are "Scottish names"
>
>Yes. WebLogic's pooling is an example of transparently
>pooling PreparedStatements (a configurable number)
>along with the connection, repeated use-patterns re-use
>the same statements indefinitely.
So the way this works is you create the PreparedStatement afresh each
time you get a new connection from the pool, but internally it notices
this is same as a previous PreparedStatement and recycles an old
PreparedStatment which may have been built on a different connection
in the pool, rather than completely building a new one??
I just learned yesterday that sometimes the Preparsed statement lives
in the driver and sometimes in the SQL engine.
O'Toole, O'Malley etc..
Arne
> On Fri, 23 Oct 2009 09:59:44 -0400, Arne Vajhøj <ar...@vajhoej.dk>
> wrote, quoted or indirectly quoted someone who said :
>
> >Prepared statement will always protect both against Scottish names
> >and malicious SQL injection.
>
> what are "Scottish names"
I interpreted this to mean strings containing characters that could be
misinterpreted if taken literally, e.g. the SQL string delimiter
appearing in a name.
See also, <http://en.wikipedia.org/wiki/SQL_injection>.
--
Sean O';Drop table users
Those are Irish names. Scottish names are like McScrooge and McKay.
--
Try to relax and enjoy the crisis.
-- Ashleigh Brilliant
Arne Vajhøj kirjoitti:
>> O'Toole, O'Malley etc..
>
Donkey Hottie wrote:
> Those are Irish names. Scottish names are like McScrooge and McKay.
>
OK, *now* it makes sense. I was extremely puzzled trying to figure
out how "MacTavish" might hurt an SQL database.
More common for Scottish surnames as well as Irish is the prefix
"Mac" ("son"). In the U.S., at least, "Mc" is common among those of
Irish ancestry rather than Scottish. Wikipedia shows "Mc" as an
Anglicization of "Mac".
<http://en.wikipedia.org/wiki/Irish_name#List_of_surnames>
<http://en.wikipedia.org/wiki/List_of_Scottish_Gaelic_surnames>
The latter link does show a couple of Scottish surnames that begin
with "O'" ("O' Luingeachain").
--
Lew
Non malicious occurrences of ' that causes SQL errors.
Arne
Ooops.
My apologies to both the Scottish and Irish.
Arne
As long as you remember this lesson, no worries.
I'm a Finn, and our names are all like *nen.
Just don't define your SQL function as
FUNCTION safe_name(name IN STRING)
RETURNS STRING
BEGIN
RETURN REPLACE(name,'nen','') ;
END ;
--
Q: How many Zen masters does it take to screw in a light bulb?
A: None. The Universe spins the bulb, and the Zen master stays out
of the way.
Correct. The SQL and any arguments to the different sorts of
prepareStatement() or prepareCall() methods will be matched to locate/
store a statement to be re-used. This saves a clientside object, and
(more importantly) any DBMS-side components, such as cursors and
execution plans etc. Ei: It avoids the DBMS having to parse the SQL
and verify the existence of the DBMS objects mentioned in the SQL
every time...
Joe Weinstein at Oracle
>> >Prepared statement will always protect both against Scottish names
>> >and malicious SQL injection.
>>
>> what are "Scottish names"
>
>I interpreted this to mean strings containing characters that could be
>misinterpreted if taken literally, e.g. the SQL string delimiter
>appearing in a name.
Since Prepared statements protect against BOTH Scottish names AND
malicious SQL injection, I take it Scottish names refer to some other
problem.
Maybe he means Irish names which contain 's which are SQL delimiters,
which would screw things up without PreparedStatement.
> On Fri, 23 Oct 2009 14:58:42 -0400, "John B. Matthews"
> <nos...@nospam.invalid> wrote, quoted or indirectly quoted someone who
> said :
>
> >> >Prepared statement will always protect both against Scottish names
> >> >and malicious SQL injection.
> >>
> >> what are "Scottish names"
> >
> >I interpreted this to mean strings containing characters that could
> >be misinterpreted if taken literally, e.g. the SQL string delimiter
> >appearing in a name.
>
> Since Prepared statements protect against BOTH Scottish names AND
> malicious SQL injection, I take it Scottish names refer to some other
> problem.
>
> Maybe he means Irish names which contain 's which are SQL delimiters,
> which would screw things up without PreparedStatement.
I'm not sure I'd pick a particular nationality; apostrophal surnames are
ubiquitous.
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
We were not expecting anything less.
:-)
Arne
There will always exist something within the client.
If the database supports prepared statements in the SQL sense,
then the driver should use that feature.
Most databases does. But JDBC spec does not required it.
Arne
The fourth Musketeer agrees with you.
See also
<http://xkcd.com/327/>
--
Lew