Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
' globals - globale Variable Dim dbfilename As String = "c:/Testdaten/formula1.db4o" ' DB-Datei Dim DB As com#db4o#ObjectContainer Dim oSet As com#db4o#ObjectSet Dim osResult As com#db4o#ObjectSet Dim pilot1 As New Pilot() Dim pilot2 As New Pilot() Dim proto As New Pilot() Dim p As New Pilot() Public Sub main(ByJava args() As String) Dim myArgs() As String myArgs = args ' [Your Source] On Error Goto ErrOut ' open database Println() Println("Open DB") DB = db4o.openFile(dbfilename) ' create pilots Println() Println("Create pilots") CreatePilots() ' store pilots Println() Println("Store pilots") StorePilots() ' read all pilots ' query by example: ' Search all objects of a class which the same field values as the sample. ' An empty prototype has in all fields Null or 0 proto.Name = Null proto.Points = 0 Println() Println("Read all pilots") osResult = DB.get(proto) ' a shorter way ' osResult = DB.get(Pilot.class) Println() ListResult(osResult) ' find pilot by name Dim name As String = "Michael Schumacher" Println() Println("Find pilot by name: " & name) FindPilotsByName(name) ' find pilot by points Dim points As Integer = 90 Println() Println("Find pilot by points: " & points) FindPilotsByPoints(points) ' update pilot Println() Println("Update pilot") UpdatePilotsByName("Michael Schumacher", 5) osResult = DB.get(Pilot.class) Println() ListResult(osResult) ' delete pilot by name Println() Println("Delete pilot: " & name) DeletePilotsByName(name) osResult = DB.get(Pilot.class) Println() ListResult(osResult) ' delete pilot by points Println() Println("Delete pilot: " & points) DeletePilotsByPoints(points) osResult = DB.get(Pilot.class) Println() ListResult(osResult) ' close db - DB schließen DB.close() Println() Println("Close DB") Println() Println("Enter ends the programm") Readln() Exit Sub ErrOut: MsgBox Err.toString() End Sub Public Sub CreatePilots() pilot1.Name = "Michael Schumacher" pilot1.Points = 100 Println(pilot1.toString()) pilot2.Name = "Rubens Barricello" pilot2.Points = 90 Println(pilot2.toString()) End Sub Sub StorePilots() DB.set(pilot1) Println(pilot1.toString()) DB.set(pilot2) Println(pilot2.toString()) End Sub Sub FindPilotsByName(name As String) proto.Name = name proto.Points = 0 osResult = DB.get(proto) Println() ListResult(osResult) End Sub Sub FindPilotsByPoints(points As Integer) proto.Name = Null proto.Points = points osResult = DB.get(proto) Println() ListResult(osResult) End Sub Sub UpdatePilotsByName(name As String, points As Integer) proto.Name = name proto.Points = 0 osResult = DB.get(proto) Do While osResult.hasNext() p = Cast(osResult.next(), Pilot) p.AddPoints(points) DB.set(p) Println(points & " points added to " + p.Name) Loop End Sub Sub DeletePilotsByName(name As String) proto.Name = name proto.Points = 0 osResult = DB.get(proto) Do While osResult.hasNext() p = Cast(osResult.next(), Pilot) DB.delete(p) Println(p.Name & " deleted") Loop End Sub Sub DeletePilotsByPoints(points As Integer) proto.Name = Null proto.Points = points osResult = DB.get(proto) Do While osResult.hasNext() p = Cast(osResult.next(), Pilot) DB.delete(p) Println(p.toString() & " deleted") Loop End Sub Sub ListResult(oSet As com#db4o#ObjectSet) Dim p As Pilot Println(oSet.size() & " Objekte in der DB.") Do While oSet.hasNext() p = Cast(oSet.next(), Pilot) Println(p.toString()) Loop End Sub Sub Println(Optional text As String) system.out.println(text) End Sub Function Readln() Readln = system.in.read() End Function |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
Private m_name As String Private m_points As Integer Public Property Get Name() As String Name = m_name End Property Public Property Let Name(value As String) m_name = value End Property Public Property Get Points() As String Points = m_points End Property Public Property Let Points(value As Integer) m_points = value End Property Public Sub AddPoints(value As Integer) m_points = m_points + value End Sub Public Function toString() toString = m_name & " / " & m_points End Function |
Intermediate
Date of registration: Jan 1st 2009
Location: Hanover, Germany
Occupation: Software Engineer
Hobbies: Hilbert Curves
Source code |
|
1 |
java -Xss4M -Xms32M -Xmx128M xyKlasse |
Trainee
Date of registration: Mar 13th 2009
Location: Oberirsen - Germany
Occupation: Senior Software Engineer
Hobbies: Programming aund Photography
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
'-Begin Class Pilot----------------------------------------------------- Private mName As String Private mPoints As Integer Public Sub Pilot(Name As String, Points As Integer) mName = Name mPoints = Points End Sub Property Get Points() Set Points = mPoints End Property Public Sub addPoints(Points As Integer) mPoints = mPoints + Points End Sub Property Get Name() Set Name = mName End Property Public Function toString() As String toString = mName & "/" & CStr(mPoints) End Function '-End Class Pilot------------------------------------------------------- |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
'-Begin----------------------------------------------------------------- Private Sub listResult(Result As ObjectSet) java#lang#System.out.println(Result.size()) Do While Result.hasNext() java#lang#System.out.println(Result.next()) Loop End Sub '----------------------------------------------------------------------- Public Sub Command1_Click() Dim db As ObjectContainer db = db4o.openFile("c:\dummy\test.db4o") Dim Pilot1 As New Pilot("Michael Schuhmacher", 100) db.store(Pilot1) java#lang#System.out.println("Stored " & Pilot1) Dim Pilot2 As New Pilot("Rubens Barrichello", 99) db.store(Pilot2) java#lang#System.out.println("Stored " & Pilot2) Dim result As ObjectSet = db.queryByExample(Pilot.class) listResult(result) db.close() End Sub '-End------------------------------------------------------------------- |
Trainee
Date of registration: Mar 13th 2009
Location: Oberirsen - Germany
Occupation: Senior Software Engineer
Hobbies: Programming aund Photography
This post has been edited 1 times, last edit by "StefanSchnell" (Jan 30th 2010, 7:25am)
Trainee
Date of registration: Mar 13th 2009
Location: Oberirsen - Germany
Occupation: Senior Software Engineer
Hobbies: Programming aund Photography