Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Berkely DB > Error in openin...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 1729 of 1800
Post > Topic >>

Error in opening Environment, and cannot create a DB file!

by lesslielee@[EMAIL PROTECTED] Apr 1, 2007 at 07:31 PM

I used simple code below, almost same as that mentioned in the BDB's
document.
My system is Linux, BDB 4.5.2, the error is : "Environment open
failed: Invalid argument". The directory "/BDB_env" I have maked. The
same error also appeared on my virtrual machine. So, I think that is
not the problem of my system.
But why? I can't open an environment, and last week I cannot create a
DB file on my disk (I did not use environment that time)?

Please help me!!!

Below is my code:

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <db.h>
#define DATABASE "testDB.db"


int main()
{
DB_ENV *myEnv;
DB *dbp;
DBT key, data;
int ret,t_ret;
u_int32_t env_flags;

//........... Create an environment object and initialize it for error
re****ting
ret = db_env_create(&myEnv, 0);
if (ret != 0)
{
fprintf(stderr, "Error creating env handle: %s\n", db_strerror(ret));
return -1;
}

//........If the environment does not exist create it. Initialize the
in-memory cache.
env_flags = DB_CREATE | DB_INIT_MPOOL;

//........Open the environment.
ret = myEnv->open(myEnv,"/BDB_env",env_flags,0);
if (ret != 0)
{
fprintf(stderr, "Environment open failed: %s", db_strerror(ret));
return -1;
}



if ((ret = db_create(&dbp, myEnv, 0)) != 0)
{
fprintf(stderr, "db_create: %s\n", db_strerror(ret));
exit (1);
}


if ((ret = dbp->open(dbp, NULL, DATABASE, NULL, DB_BTREE, DB_CREATE,
0664)) != 0)
{
dbp->err(dbp, ret, "%s", DATABASE);
exit (1);
}

if (dbp != NULL)
dbp->close(dbp, 0);

//.........close evn
//........When you are done with an environment, you must close it.
//........Before you close an environment, make sure you close any
opened databases
if (myEnv != NULL)
myEnv->close(myEnv, 0);


return 0;
}
 




 2 Posts in Topic:
Error in opening Environment, and cannot create a DB file!
lesslielee@[EMAIL PROTECT  2007-04-01 19:31:45 
Re: Error in opening Environment, and cannot create a DB file!
Florian Weimer <fw@[EM  2007-04-02 07:10:58 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Sun Jul 6 22:03:55 CDT 2008.