-3

scala swing アプリケーションから mongodb データベースにアクセスする方法を知りたいです。scala は初めてです。mongodb に mydb という名前のデータベースと、studen(rollno,name,age,city) という名前のコレクションを作成しました。私は単にmongodbデータベースでswingを使用して挿入、更新、および削除を実行したいだけですが、使用するパッケージやその他の有用な情報がわかりません。

ここにswingコードを添付しています。

Gui.scala

import swing._
import swing.event._
import swing.Component._

object Gui extends SimpleSwingApplication
{
def top = new MainFrame {
title = "Second Swing App"

val combobox = new ComboBox(List(("1"),("2"),("3"),("4"),("5"),("6"))){

}

val text1= new TextField(10){
}
val text2= new TextField(10){
}
val text3= new TextField(10){
}


val button = new Button {
text = "Clear"
}
val button1 = new Button {
text = "Save"
}
val button2 = new Button {
text = "Delete"
}

val button3 = new Button {
text = "Update"
}

val label = new Label {
text = "No button clicks registered"
}
contents = new BoxPanel(Orientation.Vertical) {
contents += combobox
contents += text1
contents += text2
contents += text3

contents += button
contents += label
contents += button1
contents += button2
contents += button3

border = Swing.EmptyBorder(30, 30, 10, 30)
}
 listenTo(button)

 reactions+={
 case ButtonClicked(button)=>


}  
}
4

1 に答える 1

3

Scala でMongoDB Java ドライバーを使用するか、Java ドライバーの Scala ラッパーであるCasbahを使用できます。

于 2010-11-11T06:24:51.710 に答える