有关db4o中的数据库连接的查询 [英] Query regarding database connectivity in db4o

查看:133
本文介绍了有关db4o中的数据库连接的查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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();

        }

我是否做对了或者是否有单独的命令来检查对象是否存在然后插入值,或者我是否可以对两个操作使用相同的代码,这意味着db4o自动检查对象是否存在于指定位置(如果存在)它将以其他方式插入对象,并在指定位置创建对象,然后插入对象.

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.

请帮助我

非常感谢

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

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.

请帮助我并指导我.

非常感谢所有人的期待

推荐答案

db4o自动更新对象,而不是插入对象,但是有一个陷阱:您必须保持对象容器处于打开状态. db4o与本地高速缓存一起使用,该高速缓存跟踪存储的对象,但是一旦在对象容器上调用close(),本地现金就消失了.如果在对象容器的close()之后存储先前持久化的对象,则会得到一个重复的对象(db4o认为这是一个新对象).如果确实需要关闭对象容器并想要更新对象,则必须在db4o上查询该对象,然后进行更新,然后调用store(然后可以关闭()).

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()).

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

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!)

这篇关于有关db4o中的数据库连接的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆