What is wrong with:
DB.use(FirstDB) {
firstConnection =>
DB.use(SecondDB) {
secondConnection =>// do transactional query between two DBs here } } Note that DB.use nests such that the transaction will only be committed when the last DB.use block for a given ConnectionIdentifier is exited. On Thu, Jan 21, 2010 at 3:17 AM, Neil.Lv <[email protected]> wrote: > > I have added the demo code on the Github now. > ( Mabye it's a bug with DB.runQuery and DB.use in the two db > vender ) > > Here is the address: > http://github.com/anim510/two_db_demo > > Thanks very much! > > Cheers, > Neil > > On Jan 21, 11:26 am, "Neil.Lv" <[email protected]> wrote: > > My email is : [email protected] > > > > On Jan 21, 11:17 am, "Neil.Lv" <[email protected]> wrote: > > > > > Mabye it's a bug with DB.runQuery and DB.use in the two db vender !!!! > > > > > Two question: (problem) > > > > > 1: I don't know why the HelloWorld snippet code will be execute 2 > > > times in this code. (See the HelloWorld.scala file.) > > > 2: The dbDefaultConnectionIdentifier method in the Model that it works > > > fine when using Mapper's method such as ModelName.findAll(), > > > it doesn't work when using DB.runQuery and DB.use(...) --- (Maybe it > > > can't find the default db identifier) > > > > > The question 2 I test it many times that found this problem. > > > > > In the test app , the Hot.getHots2 and Hot.getHots3 method can't work. > > > > > I comment the code now in the HelloWorld.scala file, you can try it. > > > > > ######## > > > > > I can push the code on the github, and get this errors "fatal: > > > unable to fork" > > > > > So If anyone know what's wrong with it and I can send the demo.tar > > > file through the email. > > > > > Thanks very much! > > > > > ######## > > > > > Cheers, > > > Neil > > > > > On Jan 21, 1:56 am, "Neil.Lv" <[email protected]> wrote: > > > > > > 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" <[email protected]> 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 <[email protected]> wrote: > > > > > > > > "Neil.Lv" <[email protected]> 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]<liftweb%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/liftweb?hl=en. > > > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics--
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.
