{"id":724,"date":"2007-10-11T23:51:38","date_gmt":"2007-10-11T22:51:38","guid":{"rendered":"http:\/\/www.craigmurphy.com\/blog\/?p=724"},"modified":"2007-10-12T12:04:05","modified_gmt":"2007-10-12T11:04:05","slug":"db4o-an-object-database","status":"publish","type":"post","link":"https:\/\/www.craigmurphy.com\/blog\/?p=724","title":{"rendered":"db4o &#8211; an object database, for .NET (and Java)"},"content":{"rendered":"<p><a href=\"http:\/\/www.craigmurphy.com\/blog\/wp-content\/uploads\/2007\/08\/db4oanobjectdatabase_14F3E\/JimPaterson.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px\" height=\"244\" alt=\"JimPaterson\" src=\"http:\/\/www.craigmurphy.com\/blog\/wp-content\/uploads\/2007\/08\/db4oanobjectdatabase_14F3E\/JimPaterson_thumb.jpg\" width=\"133\" border=\"0\"><\/a><iframe src=\"http:\/\/rcm-uk.amazon.co.uk\/e\/cm?t=craigmurphyco-21&#038;o=2&#038;p=8&#038;l=as1&#038;asins=1590596560&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr\" style=\"width:120px;height:240px;\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"0\"><\/iframe><\/p>\n<p>Last night, I was lucky enough to attend a <a href=\"http:\/\/www.scottishdevelopers.com\">Scottish Developers<\/a> meeting in Glasgow.&nbsp; It worked out rather well actually: upon arriving in Glasgow I had beer and a burger with top bloke and colleague <a href=\"http:\/\/blackhatspider.wordpress.com\/\">Alan<\/a>.&nbsp; Then the event itself.&nbsp; To finish, a beer with fellow Scottish Developers <a href=\"http:\/\/www.colinmackay.net\/\" target=\"_blank\">Colin<\/a>, <a href=\"http:\/\/www.frankkerrigan.com\/\" target=\"_blank\">Frank<\/a> and with <a href=\"http:\/\/www.sqlbits.com\">SQLBits<\/a> organiser supremo Martin.&nbsp; All in all a great trip, and a great event &#8211; you should have been there!<\/p>\n<p>Anyway, the session itself was impressive stuff.&nbsp; Whilst I had thought that the session was going to be all about an object database in Java, it turns out that <a href=\"http:\/\/www.db4o.com\/\" target=\"_blank\">db4o<\/a> has a .NET implementation too.&nbsp; And it supports the .NET Compact Framework, i.e. mobile devices.&nbsp; Speaker <a href=\"http:\/\/www.paterson.co.uk\/\" target=\"_blank\">Jim Paterson<\/a> did a really good job of explaining db4o, its use, its positives and its negatives.<\/p>\n<p>Of course, the first thing I did today was go off and download db4o and set about a simple &#8220;hello world&#8221; style example.&nbsp; True enough, everything that I saw last night worked like a charm.&nbsp; In fact, here&#8217;s the C# that I threw together in about 5 minutes:<\/p>\n<p>[code lang=&#8221;C#&#8221;]<br \/>\nusing Db4objects.Db4o;  <\/p>\n<p>namespace db40Ex<br \/>\n{<br \/>\n  public partial class Form1 : Form<br \/>\n  {<br \/>\n    IObjectContainer db;  <\/p>\n<p>    public Form1()<br \/>\n    {<br \/>\n        InitializeComponent();<br \/>\n        db = Db4oFactory.OpenFile(@&#8221;D:\\data\\_test\\db4o\\data.db4o&#8221;);<br \/>\n    }  <\/p>\n<p>    private void button1_Click(object sender, EventArgs e)<br \/>\n    {<br \/>\n       myRecord mr = new myRecord();<br \/>\n       mr.Name = &#8220;Frank Butcher&#8221;;<br \/>\n       mr.Telephone = &#8220;123 456 789&#8221;;<br \/>\n       db.Set(mr);<br \/>\n     }     <\/p>\n<p>     private void button2_Click(object sender, EventArgs e)<br \/>\n     {<br \/>\n        myRecord mr = new myRecord();<br \/>\n        IObjectSet res = db.Get(mr);<br \/>\n        listBox1.Items.Clear();<br \/>\n        foreach (myRecord s in res)<br \/>\n           listBox1.Items.Add(s.Name);<br \/>\n      }  <\/p>\n<p>     private void button3_Click(object sender, EventArgs e)<br \/>\n     {<br \/>\n         myRecord mr = new myRecord();<br \/>\n         mr.Name = &#8220;Butcher Frank&#8221;;<br \/>\n         mr.Telephone = &#8220;123 456 789&#8221;;<br \/>\n         db.Set(mr);<br \/>\n      }<br \/>\n   }  <\/p>\n<p>  public class myRecord<br \/>\n  {<br \/>\n     public string Name;<br \/>\n     public string Telephone;<br \/>\n  }<br \/>\n}<br \/>\n[\/code]<\/p>\n<p>Object databases aren&#8217;t without their pitfalls, I will use db4o in a &#8220;real&#8221; project &#8211; I am sure it&#8217;ll perform perfectly well.&nbsp; Expect to see a more detailed follow up post here shortly. <\/p>\n<p>Technorati Tags: <a href=\"http:\/\/technorati.com\/tag\/Jim+Paterson\" rel=\"tag\">Jim Paterson<\/a>, <a href=\"http:\/\/technorati.com\/tag\/object+database\" rel=\"tag\">object database<\/a>, <a href=\"http:\/\/technorati.com\/tag\/db4o\" rel=\"tag\">db4o<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last night, I was lucky enough to attend a Scottish Developers meeting in Glasgow.&nbsp; It worked out rather well actually: upon arriving in Glasgow I had beer and a burger with top bloke and colleague Alan.&nbsp; Then the event itself.&nbsp; To finish, a beer with fellow Scottish Developers Colin, Frank and with SQLBits organiser supremo &hellip; <a href=\"https:\/\/www.craigmurphy.com\/blog\/?p=724\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">db4o &#8211; an object database, for .NET (and Java)<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,22,16,3],"tags":[],"class_list":["post-724","post","type-post","status-publish","format-standard","hentry","category-net","category-community","category-developer-events","category-development"],"_links":{"self":[{"href":"https:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/724","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=724"}],"version-history":[{"count":0,"href":"https:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/724\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=724"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=724"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=724"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}