tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Darren Lee Deliang" <just_dar...@hotmail.com>
Subject RE: Indexed Properties and Resultset
Date Sat, 01 Jul 2000 09:03:59 GMT
I am using ms sql server so i think i will go the prepared statement way. 
besides the below codes as suggested by Rob, anything else i need to do on 
the ms sql server side? like i think i have to prepare a stored procedure 
rite?

Darren


>From: "Rob S." <rslifka@home.com>
>Reply-To: tomcat-user@jakarta.apache.org
>To: <tomcat-user@jakarta.apache.org>
>Subject: RE: Indexed Properties and Resultset
>Date: Fri, 30 Jun 2000 10:12:51 -0700
>
>Hi Jim,
>
> > Just want to interject a quick point to help those people who are 
>getting
> > started with Java. It's *not* a very good practice to build SQL this 
>way:
> >
> > > ResultSet rs = st.executeQuery("" +
> > >     "SELECT * FROM \"Course\" " +
> > >     "WHERE \"Deadline\" < '" + new java.util.Date() + "';");
> >
> > as it will fail when run against many databases. The appropriate way to
> > build and execute a query is to use PreparedStatement.
>
>I know it would fail because of the table and column quoting on most every
>other DB in existence, but that's seemingly-required by Postgres; is there
>another reason?  Your suggested query fails when sent to Postgres.  Maybe
>this is some option to disable somewhere, but I've used it at different
>sites on different OSs and psql (it's console) and calls in any language
>(VBS/ASP->ADO, JSP->JDBC) require these heinous quotations.
>
> > String sql = "SELECT * FROM Course WHERE Deadline < ?");
> > PreparedStatement st = conn.prepareStatement(sql);
> > st.setDate(1, new java.util.Date());
> > ResultSet rs = st.executeQuery();
>
>That's interesting...  I learned my JDBC from the Java tutorial site and it
>didn't make make mention of PreparedStatement.  I just checked the 1.2.2
>docs and lo' there it is!  Very interesting!  Thanks for the heads up =)
>
>- r
>
>
>--------------------------------------------------------------------------
>To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commmands, email: tomcat-user-help@jakarta.apache.org
>

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com


Mime
View raw message