It generated by the archetype lift-archetype-basic.

######  in the Boot.scala
object DBVendor extends ConnectionManager {
  private var pool: List[Connection] = Nil
  private var poolSize = 0
  private val maxPoolSize = 4

  private def createOne: Box[Connection] = try {
    val driverName: String = Props.get("db.driver") openOr
    "org.apache.derby.jdbc.EmbeddedDriver"

    val dbUrl: String = Props.get("db.url") openOr
    "jdbc:derby:lift_example;create=true"

    Class.forName(driverName)

    val dm = (Props.get("db.user"), Props.get("db.password")) match {
      case (Full(user), Full(pwd)) =>
        DriverManager.getConnection(dbUrl, user, pwd)

      case _ => DriverManager.getConnection(dbUrl)
    }

    Full(dm)
  } catch {
    case e: Exception => e.printStackTrace; Empty
  }

  def newConnection(name: ConnectionIdentifier): Box[Connection] =
    synchronized {
      pool match {
        case Nil if poolSize < maxPoolSize =>
          val ret = createOne
        poolSize = poolSize + 1
        ret.foreach(c => pool = c :: pool)
        ret

        case Nil => wait(1000L); newConnection(name)
        case x :: xs => try {
          x.setAutoCommit(false)
          Full(x)
        } catch {
          case e => try {
            pool = xs
            poolSize = poolSize - 1
            x.close
            newConnection(name)
          } catch {
            case e => newConnection(name)
          }
        }
      }
    }

  def releaseConnection(conn: Connection): Unit = synchronized {
    pool = conn :: pool
    notify
  }
}

######

   And this is my default.props (In src\main\resources\props )
   Only this file in the props folder.

###
db.driver=com.mysql.jdbc.Driver
db.url=jdbc:mysql://localhost:3306/project
db.user=root
db.password=root
###

Cheers,
  Neil


On Nov 28, 7:57 pm, Timothy Perrett <[email protected]> wrote:
> Paste your database connection object? its probably that you copied the one 
> from lift examples and you are now missing the correct properties file...
>
> Cheers, Tim
>
> On 28 Nov 2009, at 10:26, Neil.Lv wrote:
>
> > Hi all,
>
> >   I have a silly question about the lift app that deployed on the
> > Jetty server.
>
> >   Can't find the jdbc:mysql driver in Production Mode ? It will use
> > the derby to instead of the mysql.
>
> >  But it works fine in the Development Mode.
>
> >  I will craete the derby file in the jetty folder.
> >  /home/jetty6/derby.log
> >  /home/jetty6/lift-example
>
> >  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 
> > 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 [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