db4o 中有关数据库连接的查询

发布于 2024-10-31 10:29:37 字数 765 浏览 1 评论 0原文

我正在创建一个 db4o 对象(即 Customer.yap),如果它已经创建,我只需将新对象插入到现有对象(即 Customer.yap)中。

对于这两个操作,我只是使用:

IObjectContainer db1 = Db4oEmbedded.OpenFile(Db4oEmbedded.NewConfiguration(),@"C:\Users\admin\Desktop\Db4oObjectFiles\Components.yap");

        try

        {

            db1.Store(comp1);

        }



        finally

        {

            db1.Close();

        }

我做对了吗?或者是否有一个单独的命令来检查对象是否存在,然后插入值,或者我可以对这两个操作使用相同的代码,这意味着 db4o 自动检查对象是否存在如果存在,则在指定位置插入对象,否则在指定位置创建对象,然后插入对象。

请帮助我

期待中的感谢

PS:我是在 asp.net 中的 Web 应用程序上下文中执行此操作的,然后这个想法始终潜伏在我的脑海中。我不应该使用远程连接而不是将其存储在实际的物理位置,但我无法仅仅弄清楚某人如何在远程连接的上下文中创建和存储对象。我不知道要指定哪些参数,即主机、端口用户名和密码,我什至不知道如何创建数据库连接以及应该在程序中编写哪些语句来连接到此远程对象文件。

请帮助我并指导我。

非常感谢所有期待的人

I'm creating a db4o object (namely Customer.yap) and if it is already created i just insert new objects into the existing object (namely Customer.yap) .

For both these operations i'm just using:

IObjectContainer db1 = Db4oEmbedded.OpenFile(Db4oEmbedded.NewConfiguration(),@"C:\Users\admin\Desktop\Db4oObjectFiles\Components.yap");

        try

        {

            db1.Store(comp1);

        }



        finally

        {

            db1.Close();

        }

Am i doing it right or is there a separate command to check if the object exists and then insert values or can i use the same code for both the operations meaning db4o automatically checks if the object exists at the specified location if it exists it inserts the objects other wise it creates the object at the specified location and then insert the object.

Please help me

Thanks in anticipation

PS: i'm doing this in the context of web application in asp.net and then there is this thought that is always lurking in my mind. should n't i be using the remote connection rather than storing it in actual physical location, but i could n't just figure it how does someone create and store objects in the context of remote connection. i don't know which parameters to specify namely host, port username and password and i even don't know how does some one create database connection what r the statements one should write in the program to connect to this remote object file.

Please please help me and guide me.

A big thanks to anyone in anticipation

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独自←快乐 2024-11-07 10:29:37

db4o 自动更新对象而不是插入它,但有一个问题:您必须保持对象容器打开。 db4o 使用本地缓存来跟踪存储的对象,但是一旦您在对象容器上调用 close() ,本地现金就会消失。如果您在对象容器上存储 close() 之后先前保留的对象,您将得到一个重复的对象(db4o 认为它是一个新对象)。如果您确实必须关闭对象容器并想要更新对象,则必须在 db4o 上查询它,然后更新,然后调用 store(然后您可以 close())。

关于如何连接远程db4o服务器请参见:
http://developer.db4o .com/Documentation/Reference/db4o-7.12/java/reference/Content/client-server/networked.htm

最好! (祝你好运!)

db4o automatically updates the object instead of inserting it but there's a catch: you'll have to keep your object container open. db4o works with a local cache that keeps track of stored objects, but once you call close() on the object container that local cash is gone. If you store a previously persisted after a close() on the object container you'll get a duplicate object (db4o thinks it's a new one). If you really have to close the object container and want to update an object you'll have to query for it on db4o, then update, then call store (and then you can close()).

With regards to how to connect to a remote db4o server please see:
http://developer.db4o.com/Documentation/Reference/db4o-7.12/java/reference/Content/client-server/networked.htm

Best! (good luck!)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文