[Lift] Re: How to configure two database connection in Lift?
In the Boot.scala ### class Boot { def boot { if (!DB.jndiJdbcConnAvailable_?) DB.defineConnectionManager(DefaultConnectionIdentifier, DBVendor) ... } } object WahDB extends ConnectionIdentifier { def jndiName = one } object WahereDB extends ConnectionIdentifier { def jndiName = two } object DBVendor extends ConnectionManager { ... private def createOne(name: ConnectionIdentifier): Box[Connection] = try { val dbUrl1: String = Props.get(db.url1) openOr jdbc:derby:lift_example;create=true val dbUrl2: String = Props.get(db.url2) openOr jdbc:derby:lift_example;create=true var dbUrl: String = dbUrl1 try{ name match { case One = { dbUrl = dbUrl1 } case Two = { dbUrl = dbUrl2 } case lift = { dbUrl = dbUrl1 } } } catch { case e : Exception = e.printStackTrace; Empty } ... } ... } In the every models: class User extends MegaProtoUser[User] { def getSingleton = User // what's the meta server ... override def dbCalculateConnectionIdentifier = { // ## dbCalculateConnectionIdentifier case _ = One } } class Blog extends LongKeyedMapper[Item] with IdPK { def getSingleton = Blog // what's the meta server ... override def dbCalculateConnectionIdentifier = { // ## dbCalculateConnectionIdentifier case _ = Two } } ### I add the override def dbCalculateConnectionIdentifier method in every models But everytime it uses the database One, never uses the database Two. Thanks very much! Cheers, Neil On Dec 6, 3:02 pm, Neil.Lv anim...@gmail.com wrote: The two databases that have different structure of the tables, such as two applications databases. Cheers, Neil On Dec 6, 2:38 pm, Neil.Lv anim...@gmail.com wrote: Btw, there is the error message when the server is started. ### scala.MatchError: ConnectionIdentifier(lift) ### On Dec 6, 1:47 pm, Neil.Lv anim...@gmail.com wrote: Hi all, I want to use two databases, but i don't know how to configure it. Does anybody know that how to configure two database connection in Lift? 1: I add two ConnectionIdentifier in the Boot.class ### object OneDB extends ConnectionIdentifier { def jndiName = one } object TwoDB extends ConnectionIdentifier { def jndiName = two } ### 2: In the User model How can i write the code in the method, ### override def dbCalculateConnectionIdentifier = { Two } ### 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 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.
[Lift] Re: How to configure two database connection in Lift?
Here is the db url, db.url1=jdbc:mysql://localhost:3306/blog1 db.url2=jdbc:mysql://localhost:3306/blog2 Cheers, Neil On Dec 6, 4:00 pm, Neil.Lv anim...@gmail.com wrote: In the Boot.scala ### class Boot { def boot { if (!DB.jndiJdbcConnAvailable_?) DB.defineConnectionManager(DefaultConnectionIdentifier, DBVendor) ... } } object WahDB extends ConnectionIdentifier { def jndiName = one} object WahereDB extends ConnectionIdentifier { def jndiName = two } object DBVendor extends ConnectionManager { ... private def createOne(name: ConnectionIdentifier): Box[Connection] = try { val dbUrl1: String = Props.get(db.url1) openOr jdbc:derby:lift_example;create=true val dbUrl2: String = Props.get(db.url2) openOr jdbc:derby:lift_example;create=true var dbUrl: String = dbUrl1 try{ name match { case One = { dbUrl = dbUrl1 } case Two = { dbUrl = dbUrl2 } case lift = { dbUrl = dbUrl1 } } } catch { case e : Exception = e.printStackTrace; Empty } ... } ... } In the every models: class User extends MegaProtoUser[User] { def getSingleton = User // what's the meta server ... override def dbCalculateConnectionIdentifier = { // ## dbCalculateConnectionIdentifier case _ = One } } class Blog extends LongKeyedMapper[Item] with IdPK { def getSingleton = Blog // what's the meta server ... override def dbCalculateConnectionIdentifier = { // ## dbCalculateConnectionIdentifier case _ = Two }} ### I add the override def dbCalculateConnectionIdentifier method in every models But everytime it uses the database One, never uses the database Two. Thanks very much! Cheers, Neil On Dec 6, 3:02 pm, Neil.Lv anim...@gmail.com wrote: The two databases that have different structure of the tables, such as two applications databases. Cheers, Neil On Dec 6, 2:38 pm, Neil.Lv anim...@gmail.com wrote: Btw, there is the error message when the server is started. ### scala.MatchError: ConnectionIdentifier(lift) ### On Dec 6, 1:47 pm, Neil.Lv anim...@gmail.com wrote: Hi all, I want to use two databases, but i don't know how to configure it. Does anybody know that how to configure two database connection in Lift? 1: I add two ConnectionIdentifier in the Boot.class ### object OneDB extends ConnectionIdentifier { def jndiName = one } object TwoDB extends ConnectionIdentifier { def jndiName = two } ### 2: In the User model How can i write the code in the method, ### override def dbCalculateConnectionIdentifier = { Two } ### 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 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.
[Lift] Re: How to configure two database connection in Lift?
If i remove the DB.defineConnectionManager (DefaultConnectionIdentifier, DBVendor) This error message occurs. ### java.lang.NullPointerException: Looking for Connection Identifier ConnectionIden tifier(lift) but failed to find either a JNDI data source with the name lift or a lift connection manager with the correct name ### Cheers, Neil On Dec 6, 7:54 pm, Tim Nelson tnell...@gmail.com wrote: Hi, This line configures the database connections: DB.defineConnectionManager(DefaultConnectionIdentifier, DBVendor) This is using only the DefaultConnectionIdentifier, which you don't want to use. You want to change this to use your 2 defined identifiers. Ie: DB.defineConnectionManager(OneDB, DBVendor) DB.defineConnectionManager(TwoDB, DBVendor) Tim On Sun, Dec 6, 2009 at 4:17 AM, Neil.Lv anim...@gmail.com wrote: Here is the db url, db.url1=jdbc:mysql://localhost:3306/blog1 db.url2=jdbc:mysql://localhost:3306/blog2 Cheers, Neil On Dec 6, 4:00 pm, Neil.Lv anim...@gmail.com wrote: In the Boot.scala ### class Boot { def boot { if (!DB.jndiJdbcConnAvailable_?) DB.defineConnectionManager(DefaultConnectionIdentifier, DBVendor) ... } } object WahDB extends ConnectionIdentifier { def jndiName = one} object WahereDB extends ConnectionIdentifier { def jndiName = two } object DBVendor extends ConnectionManager { ... private def createOne(name: ConnectionIdentifier): Box[Connection] = try { val dbUrl1: String = Props.get(db.url1) openOr jdbc:derby:lift_example;create=true val dbUrl2: String = Props.get(db.url2) openOr jdbc:derby:lift_example;create=true var dbUrl: String = dbUrl1 try{ name match { case One = { dbUrl = dbUrl1 } case Two = { dbUrl = dbUrl2 } case lift = { dbUrl = dbUrl1 } } } catch { case e : Exception = e.printStackTrace; Empty } ... } ... } In the every models: class User extends MegaProtoUser[User] { def getSingleton = User // what's the meta server ... override def dbCalculateConnectionIdentifier = { // ## dbCalculateConnectionIdentifier case _ = One } } class Blog extends LongKeyedMapper[Item] with IdPK { def getSingleton = Blog // what's the meta server ... override def dbCalculateConnectionIdentifier = { // ## dbCalculateConnectionIdentifier case _ = Two }} ### I add the override def dbCalculateConnectionIdentifier method in every models But everytime it uses the database One, never uses the database Two. Thanks very much! Cheers, Neil On Dec 6, 3:02 pm, Neil.Lv anim...@gmail.com wrote: The two databases that have different structure of the tables, such as two applications databases. Cheers, Neil On Dec 6, 2:38 pm, Neil.Lv anim...@gmail.com wrote: Btw, there is the error message when the server is started. ### scala.MatchError: ConnectionIdentifier(lift) ### On Dec 6, 1:47 pm, Neil.Lv anim...@gmail.com wrote: Hi all, I want to use two databases, but i don't know how to configure it. Does anybody know that how to configure two database connection in Lift? 1: I add two ConnectionIdentifier in the Boot.class ### object OneDB extends ConnectionIdentifier { def jndiName = one } object TwoDB extends ConnectionIdentifier { def jndiName = two } ### 2: In the User model How can i write the code in the method, ### override def dbCalculateConnectionIdentifier = { Two } ### 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 lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/liftweb?hl=en. -- 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.
[Lift] Re: How to configure two database connection in Lift?
I don't understand the jndiName whether the jndiName is whatever string that i can specify ? ### object OneDB extends ConnectionIdentifier { def jndiName = one } ### Cheers, Neil On Dec 6, 7:54 pm, Tim Nelson tnell...@gmail.com wrote: Hi, This line configures the database connections: DB.defineConnectionManager(DefaultConnectionIdentifier, DBVendor) This is using only the DefaultConnectionIdentifier, which you don't want to use. You want to change this to use your 2 defined identifiers. Ie: DB.defineConnectionManager(OneDB, DBVendor) DB.defineConnectionManager(TwoDB, DBVendor) Tim On Sun, Dec 6, 2009 at 4:17 AM, Neil.Lv anim...@gmail.com wrote: Here is the db url, db.url1=jdbc:mysql://localhost:3306/blog1 db.url2=jdbc:mysql://localhost:3306/blog2 Cheers, Neil On Dec 6, 4:00 pm, Neil.Lv anim...@gmail.com wrote: In the Boot.scala ### class Boot { def boot { if (!DB.jndiJdbcConnAvailable_?) DB.defineConnectionManager(DefaultConnectionIdentifier, DBVendor) ... } } object WahDB extends ConnectionIdentifier { def jndiName = one} object WahereDB extends ConnectionIdentifier { def jndiName = two } object DBVendor extends ConnectionManager { ... private def createOne(name: ConnectionIdentifier): Box[Connection] = try { val dbUrl1: String = Props.get(db.url1) openOr jdbc:derby:lift_example;create=true val dbUrl2: String = Props.get(db.url2) openOr jdbc:derby:lift_example;create=true var dbUrl: String = dbUrl1 try{ name match { case One = { dbUrl = dbUrl1 } case Two = { dbUrl = dbUrl2 } case lift = { dbUrl = dbUrl1 } } } catch { case e : Exception = e.printStackTrace; Empty } ... } ... } In the every models: class User extends MegaProtoUser[User] { def getSingleton = User // what's the meta server ... override def dbCalculateConnectionIdentifier = { // ## dbCalculateConnectionIdentifier case _ = One } } class Blog extends LongKeyedMapper[Item] with IdPK { def getSingleton = Blog // what's the meta server ... override def dbCalculateConnectionIdentifier = { // ## dbCalculateConnectionIdentifier case _ = Two }} ### I add the override def dbCalculateConnectionIdentifier method in every models But everytime it uses the database One, never uses the database Two. Thanks very much! Cheers, Neil On Dec 6, 3:02 pm, Neil.Lv anim...@gmail.com wrote: The two databases that have different structure of the tables, such as two applications databases. Cheers, Neil On Dec 6, 2:38 pm, Neil.Lv anim...@gmail.com wrote: Btw, there is the error message when the server is started. ### scala.MatchError: ConnectionIdentifier(lift) ### On Dec 6, 1:47 pm, Neil.Lv anim...@gmail.com wrote: Hi all, I want to use two databases, but i don't know how to configure it. Does anybody know that how to configure two database connection in Lift? 1: I add two ConnectionIdentifier in the Boot.class ### object OneDB extends ConnectionIdentifier { def jndiName = one } object TwoDB extends ConnectionIdentifier { def jndiName = two } ### 2: In the User model How can i write the code in the method, ### override def dbCalculateConnectionIdentifier = { Two } ### 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 lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/liftweb?hl=en. -- 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.
Re: [Lift] Re: How to configure two database connection in Lift?
I think there might be a problem with the way you are specifying which db to use in your mapper classes. Here's the relevant text from the The Lift Book: dbSelect... is used to find an instance by primary key, and takes a partial function (typically a match clause) to determine which connection to use. dbCalculate... is used when a new instance is created to decide where to store the new instance. Those 2 methods are used for sharding. Are you sharding? If not I think you just want to override dbDefaultConnectionIdentifier Tim On Sun, Dec 6, 2009 at 6:01 AM, Neil.Lv anim...@gmail.com wrote: If i remove the DB.defineConnectionManager (DefaultConnectionIdentifier, DBVendor) This error message occurs. ### java.lang.NullPointerException: Looking for Connection Identifier ConnectionIden tifier(lift) but failed to find either a JNDI data source with the name lift or a lift connection manager with the correct name ### Cheers, Neil On Dec 6, 7:54 pm, Tim Nelson tnell...@gmail.com wrote: Hi, This line configures the database connections: DB.defineConnectionManager(DefaultConnectionIdentifier, DBVendor) This is using only the DefaultConnectionIdentifier, which you don't want to use. You want to change this to use your 2 defined identifiers. Ie: DB.defineConnectionManager(OneDB, DBVendor) DB.defineConnectionManager(TwoDB, DBVendor) Tim On Sun, Dec 6, 2009 at 4:17 AM, Neil.Lv anim...@gmail.com wrote: Here is the db url, db.url1=jdbc:mysql://localhost:3306/blog1 db.url2=jdbc:mysql://localhost:3306/blog2 Cheers, Neil On Dec 6, 4:00 pm, Neil.Lv anim...@gmail.com wrote: In the Boot.scala ### class Boot { def boot { if (!DB.jndiJdbcConnAvailable_?) DB.defineConnectionManager(DefaultConnectionIdentifier, DBVendor) ... } } object WahDB extends ConnectionIdentifier { def jndiName = one} object WahereDB extends ConnectionIdentifier { def jndiName = two } object DBVendor extends ConnectionManager { ... private def createOne(name: ConnectionIdentifier): Box[Connection] = try { val dbUrl1: String = Props.get(db.url1) openOr jdbc:derby:lift_example;create=true val dbUrl2: String = Props.get(db.url2) openOr jdbc:derby:lift_example;create=true var dbUrl: String = dbUrl1 try{ name match { case One = { dbUrl = dbUrl1 } case Two = { dbUrl = dbUrl2 } case lift = { dbUrl = dbUrl1 } } } catch { case e : Exception = e.printStackTrace; Empty } ... } ... } In the every models: class User extends MegaProtoUser[User] { def getSingleton = User // what's the meta server ... override def dbCalculateConnectionIdentifier = { // ## dbCalculateConnectionIdentifier case _ = One } } class Blog extends LongKeyedMapper[Item] with IdPK { def getSingleton = Blog // what's the meta server ... override def dbCalculateConnectionIdentifier = { // ## dbCalculateConnectionIdentifier case _ = Two }} ### I add the override def dbCalculateConnectionIdentifier method in every models But everytime it uses the database One, never uses the database Two. Thanks very much! Cheers, Neil On Dec 6, 3:02 pm, Neil.Lv anim...@gmail.com wrote: The two databases that have different structure of the tables, such as two applications databases. Cheers, Neil On Dec 6, 2:38 pm, Neil.Lv anim...@gmail.com wrote: Btw, there is the error message when the server is started. ### scala.MatchError: ConnectionIdentifier(lift) ### On Dec 6, 1:47 pm, Neil.Lv anim...@gmail.com wrote: Hi all, I want to use two databases, but i don't know how to configure it. Does anybody know that how to configure two database connection in Lift? 1: I add two ConnectionIdentifier in the Boot.class ### object OneDB extends ConnectionIdentifier { def jndiName = one } object TwoDB extends ConnectionIdentifier { def jndiName = two } ### 2: In the User model How can i write the code in the method, ### override def dbCalculateConnectionIdentifier = { Two } ### 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 lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/liftweb?hl=en. -- You received this message because you are
[Lift] Re: How to configure two database connection in Lift?
Yeah, i don't want to use sharding, i just want select some information from another databases, ### object Blog extends Blog with LongKeyedMetaMapper[Blog ] { ... override def dbDefaultConnectionIdentifier = OneDB ... } ### It doesn't work, maybe the code that i write is wrong ? Cheers, Neil On Dec 6, 8:28 pm, Tim Nelson tnell...@gmail.com wrote: I think there might be a problem with the way you are specifying which db to use in your mapper classes. Here's the relevant text from the The Lift Book: dbSelect... is used to find an instance by primary key, and takes a partial function (typically a match clause) to determine which connection to use. dbCalculate... is used when a new instance is created to decide where to store the new instance. Those 2 methods are used for sharding. Are you sharding? If not I think you just want to override dbDefaultConnectionIdentifier Tim On Sun, Dec 6, 2009 at 6:01 AM, Neil.Lv anim...@gmail.com wrote: If i remove the DB.defineConnectionManager (DefaultConnectionIdentifier, DBVendor) This error message occurs. ### java.lang.NullPointerException: Looking for Connection Identifier ConnectionIden tifier(lift) but failed to find either a JNDI data source with the name lift or a lift connection manager with the correct name ### Cheers, Neil On Dec 6, 7:54 pm, Tim Nelson tnell...@gmail.com wrote: Hi, This line configures the database connections: DB.defineConnectionManager(DefaultConnectionIdentifier, DBVendor) This is using only the DefaultConnectionIdentifier, which you don't want to use. You want to change this to use your 2 defined identifiers. Ie: DB.defineConnectionManager(OneDB, DBVendor) DB.defineConnectionManager(TwoDB, DBVendor) Tim On Sun, Dec 6, 2009 at 4:17 AM, Neil.Lv anim...@gmail.com wrote: Here is the db url, db.url1=jdbc:mysql://localhost:3306/blog1 db.url2=jdbc:mysql://localhost:3306/blog2 Cheers, Neil On Dec 6, 4:00 pm, Neil.Lv anim...@gmail.com wrote: In the Boot.scala ### class Boot { def boot { if (!DB.jndiJdbcConnAvailable_?) DB.defineConnectionManager(DefaultConnectionIdentifier, DBVendor) ... } } object WahDB extends ConnectionIdentifier { def jndiName = one} object WahereDB extends ConnectionIdentifier { def jndiName = two } object DBVendor extends ConnectionManager { ... private def createOne(name: ConnectionIdentifier): Box[Connection] = try { val dbUrl1: String = Props.get(db.url1) openOr jdbc:derby:lift_example;create=true val dbUrl2: String = Props.get(db.url2) openOr jdbc:derby:lift_example;create=true var dbUrl: String = dbUrl1 try{ name match { case One = { dbUrl = dbUrl1 } case Two = { dbUrl = dbUrl2 } case lift = { dbUrl = dbUrl1 } } } catch { case e : Exception = e.printStackTrace; Empty } ... } ... } In the every models: class User extends MegaProtoUser[User] { def getSingleton = User // what's the meta server ... override def dbCalculateConnectionIdentifier = { // ## dbCalculateConnectionIdentifier case _ = One } } class Blog extends LongKeyedMapper[Item] with IdPK { def getSingleton = Blog // what's the meta server ... override def dbCalculateConnectionIdentifier = { // ## dbCalculateConnectionIdentifier case _ = Two }} ### I add the override def dbCalculateConnectionIdentifier method in every models But everytime it uses the database One, never uses the database Two. Thanks very much! Cheers, Neil On Dec 6, 3:02 pm, Neil.Lv anim...@gmail.com wrote: The two databases that have different structure of the tables, such as two applications databases. Cheers, Neil On Dec 6, 2:38 pm, Neil.Lv anim...@gmail.com wrote: Btw, there is the error message when the server is started. ### scala.MatchError: ConnectionIdentifier(lift) ### On Dec 6, 1:47 pm, Neil.Lv anim...@gmail.com wrote: Hi all, I want to use two databases, but i don't know how to configure it. Does anybody know that how to configure two database connection in Lift? 1: I add two ConnectionIdentifier in the Boot.class ### object OneDB extends ConnectionIdentifier { def jndiName = one } object TwoDB extends ConnectionIdentifier { def jndiName = two } ### 2: In the User model How can i write the code in the method, ### override def
Re: [Lift] Re: How to configure two database connection in Lift?
I did some more digging and got a sample app to work. You can see the code here: http://github.com/eltimn/lift_1_1_sample There are 2 things I had to do. The first is to pass in the DbId when calling Schemifier; Schemifier.schemify(true, Log.infoF _, OneDB, User) Schemifier.schemify(true, Log.infoF _, TwoDB, Dog) This was the cause of the NPE earlier. The second thing I did was to create 2 separate DBVendor objects. I could not get this to work with one that matches on the ConnectionIdentifier, like the example in The Lift Book. I didn't dig into why this wasn't working, so it could be the way the code is written. DB.defineConnectionManager(OneDB, DBVendor_1) DB.defineConnectionManager(TwoDB, DBVendor_2) Tim -- 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.
[Lift] Re: How to configure two database connection in Lift?
Thanks Tim, I have tried it in my code but it doesn't work yet! The lift version is: 1.1-M7 Scala Version is: 2.7.7 Cheers, Neil On Dec 6, 10:52 pm, Tim Nelson tnell...@gmail.com wrote: I did some more digging and got a sample app to work. You can see the code here:http://github.com/eltimn/lift_1_1_sample There are 2 things I had to do. The first is to pass in the DbId when calling Schemifier; Schemifier.schemify(true, Log.infoF _, OneDB, User) Schemifier.schemify(true, Log.infoF _, TwoDB, Dog) This was the cause of the NPE earlier. The second thing I did was to create 2 separate DBVendor objects. I could not get this to work with one that matches on the ConnectionIdentifier, like the example in The Lift Book. I didn't dig into why this wasn't working, so it could be the way the code is written. DB.defineConnectionManager(OneDB, DBVendor_1) DB.defineConnectionManager(TwoDB, DBVendor_2) Tim -- 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.
[Lift] Re: How to configure two database connection in Lift?
It works now, I missing the dbDefaultConnectionIdentifier definition in the others models. Thank you very much! :) Cheers, Neil On Dec 7, 12:06 am, Neil.Lv anim...@gmail.com wrote: Thanks Tim, I have tried it in my code but it doesn't work yet! The lift version is: 1.1-M7 Scala Version is: 2.7.7 Cheers, Neil On Dec 6, 10:52 pm, Tim Nelson tnell...@gmail.com wrote: I did some more digging and got a sample app to work. You can see the code here:http://github.com/eltimn/lift_1_1_sample There are 2 things I had to do. The first is to pass in the DbId when calling Schemifier; Schemifier.schemify(true, Log.infoF _, OneDB, User) Schemifier.schemify(true, Log.infoF _, TwoDB, Dog) This was the cause of the NPE earlier. The second thing I did was to create 2 separate DBVendor objects. I could not get this to work with one that matches on the ConnectionIdentifier, like the example in The Lift Book. I didn't dig into why this wasn't working, so it could be the way the code is written. DB.defineConnectionManager(OneDB, DBVendor_1) DB.defineConnectionManager(TwoDB, DBVendor_2) Tim -- 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.
[Lift] Re: How to configure two database connection in Lift?
Btw, there is the error message when the server is started. ### scala.MatchError: ConnectionIdentifier(lift) ### On Dec 6, 1:47 pm, Neil.Lv anim...@gmail.com wrote: Hi all, I want to use two databases, but i don't know how to configure it. Does anybody know that how to configure two database connection in Lift? 1: I add two ConnectionIdentifier in the Boot.class ### object OneDB extends ConnectionIdentifier { def jndiName = one } object TwoDB extends ConnectionIdentifier { def jndiName = two } ### 2: In the User model How can i write the code in the method, ### override def dbCalculateConnectionIdentifier = { Two } ### 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 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.
Re: [Lift] Re: How to configure two database connection in Lift?
I haven't used multiple connections myself, but I think you have two issues, 1) The default connection identifier is lift so you have to define a connection with that name otherwise you'll have to override all Mapper objects to use a different connection. 2) Your dbCalculateConnectionIdentifier method should look like, override def dbCalculateConnectionIdentifier = { case _ = Two } meaning, regarless of the mapped object's value, use connection Two. and if you always use the same connection for all objects of a given mapper (i.e., you're not sharding) then you can alternatively override the MetaMapper object's dbDefaultConnectionIdentifier method. Hope this helps, alex On Sat, Dec 5, 2009 at 10:38 PM, Neil.Lv anim...@gmail.com wrote: Btw, there is the error message when the server is started. ### scala.MatchError: ConnectionIdentifier(lift) ### On Dec 6, 1:47 pm, Neil.Lv anim...@gmail.com wrote: Hi all, I want to use two databases, but i don't know how to configure it. Does anybody know that how to configure two database connection in Lift? 1: I add two ConnectionIdentifier in the Boot.class ### object OneDB extends ConnectionIdentifier { def jndiName = one } object TwoDB extends ConnectionIdentifier { def jndiName = two } ### 2: In the User model How can i write the code in the method, ### override def dbCalculateConnectionIdentifier = { Two } ### 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 lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- 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.
[Lift] Re: How to configure two database connection in Lift?
The two databases that have different structure of the tables, such as two applications databases. Cheers, Neil On Dec 6, 2:38 pm, Neil.Lv anim...@gmail.com wrote: Btw, there is the error message when the server is started. ### scala.MatchError: ConnectionIdentifier(lift) ### On Dec 6, 1:47 pm, Neil.Lv anim...@gmail.com wrote: Hi all, I want to use two databases, but i don't know how to configure it. Does anybody know that how to configure two database connection in Lift? 1: I add two ConnectionIdentifier in the Boot.class ### object OneDB extends ConnectionIdentifier { def jndiName = one } object TwoDB extends ConnectionIdentifier { def jndiName = two } ### 2: In the User model How can i write the code in the method, ### override def dbCalculateConnectionIdentifier = { Two } ### 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 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.