The DB.runQuery can works now, but the DB.prepareStatement also
cant' work.

  Here is the test app address:
  http://github.com/anim510/two_db_demo

Cheers,
  Neil

On Jan 21, 1:16 am, "Neil.Lv" <anim...@gmail.com> wrote:
>    Thank you very much,
>
>    But it doesn't work yet, maybe because of using two db connections.
>
>    I'll test it later again.
>
> On Jan 21, 12:44 am, Jeppe Nejsum Madsen <je...@ingolfs.dk> wrote:
>
> > "Neil.Lv" <anim...@gmail.com> writes:
> > > Hi all,
>
> > >   I use two db connections in my app, and I want to use
> > > DB.prepareStatement to select
> > > the records from the second db.
>
> > >   It failed, Here is the code:
> > > ###
> > >   def getHotByTid(id : Long) =
> > >     DB.use(bootstrap.liftweb.TwoDB) {
> > >       conn =>
> > >      DB.prepareStatement("SELECT * FROM hots WHERE id=? ", conn) {
> > >              stmt =>
> > >                      stmt.setLong(1, id)
> > > Log.info("stmt :" + stmt)   // The information is correctly now, but
> > > after call executeUpdate method
> > >                      stmt.executeUpdate()
> > >       }
> > >    }
>
> > Not sure what your problem is really, but I think you should use
> > DB.runQuery to execute a select statement
>
> > Ie
>
> >   val (_,result) = DB.runQuery("SELECT COUNT(*), contract_length  FROM "+
> >                     "vehicles_current v "+
> >                     "WHERE v.account_id=? "+
> >                     "GROUP BY contract_length "+
> >                     "ORDER BY contract_length",
> >                     List(42))
>
> > /Jeppe
-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.


Reply via email to