Got it, thank you very much!

   :)

Cheers,
  Neil

On Dec 19, 11:02 pm, Marcin Jurczuk <[email protected]> wrote:
> Neil,
>
> from java.SQL:
>  return INT - executeUpdate()
>           Executes the SQL statement in this PreparedStatement object,
> which must be an SQL INSERT, UPDATE or DELETE statement; or an SQL
> statement that returns nothing, such as a DDL statement.
>
>  return ResultSet       executeQuery()
>           Executes the SQL query in this PreparedStatement object and
> returns the ResultSet object generated by the query.
>
> FYI
>
> Marcin,
>
> On 19 Gru, 08:26, "Neil.Lv" <[email protected]> wrote:
>
> >  It works now.
>
> >  I use the same executeUpdate method, and it can insert into the db.
>
> >  Thanks Marcin,
>
> > Cheers,
> >   Neil
>
> > On Dec 19, 1:29 am, "Neil.Lv" <[email protected]> wrote:
>
> > > Hi Marcin,
>
> > >    Thank you very much! The update statement works now!
>
> > >    There is a question about the insert statement, how can i use the
> > > prepareStatement ?
>
> > > ###
> > >   "INSERT INTO blogs click_counts=100 WHERE id=1"
> > > ###
>
> > >    I'm not familiar with it,
>
> > >    Thanks very much!
>
> > >    :)
>
> > > Cheers,
> > >   Neil
>
> > > On Dec 18, 11:13 pm, Marcin Jurczuk <[email protected]> wrote:
>
> > > > Hi,
>
> > > > You have few options:
> > > > - DB.runQuery("UPDATE blogs set click_counts=click_counts+1 WHERE
> > > > id=1")
> > > > - DBprepareStatement("UPDATE blogs set click_counts=click_counts+1
> > > > WHERE id=?",yourDBConnection) {
> > > > stmt =>
> > > > stmt.setLong(1,1)
> > > > stmt.executeUpdate()}
>
> > > > Where first 1 in setLong is position in prepared statment where you
> > > > will put second value. Since You have only one ? it always will be
> > > > "1".
>
> > > > WARNING:
> > > > runQuery is vulnerable to SQL injection in many situations (mostly
> > > > where string is passed to query)
>
> > > > Marcin,
>
> > > > On 18 Gru, 15:45, "Neil.Lv" <[email protected]> wrote:
>
> > > > > Hi all,
>
> > > > >    How can i update and insert record into database via Raw sql in
> > > > > Lift?
>
> > > > >    I write some code but it failed, here is :
>
> > > > > ### In the model
>
> > > > >   def updateClickCountsById(id: Long) =
> > > > >     DB.runQuery("UPDATE blogs set click_counts=click_counts+1 WHERE
> > > > > id=1")
>
> > > > >   def insertRecord() =
> > > > >     DB.runQuery("INSERT INTO blogs click_counts=100 WHERE id=1")
>
> > > > > ###
>
> > > > >    This two method doesn't work, so how can i update and insert via
> > > > > raw SQL in the lift with Mapper?
>
> > > > >    Thanks for any suggestion !
>
> > > > > Cheers,
> > > > >   Neil

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.


Reply via email to