Using a database

Hi,
I want to use a database for storing a certain information (e.g phone numbers for my contacts). I want the information to be stored even if my application is not running so when I close my application the data will still be in the database.
I tried using HSQL but I have no idea how I create my own database for creating tables. What database should I use for this purpose ? I need the database to allow me to access/update existing tables through my application.
thx.

Javaist wrote:
Hi,
I want to use a database for storing a certain information (e.g phone numbers for my contacts). I want the information to be stored even if my application is not running so when I close my application the data will still be in the database.That is how databases work.
I tried using HSQL but I have no idea how I create my own database for creating tables. What database should I use for this purpose ? Since you haven't actually provided any requirements the answer would be any database. Or even just use a file.
I need the database to allow me to access/update existing tables through my application.Any database.

Similar Messages

  • How to use Logical database in function module?

    I will create a function module in HR.
    but how to use Logical database  in function module ?  Logical database PNP always show screen.in function (RFC) code , it is a matter.

    You cannot attach the LDB to the main program of the function group.
    - So you may [SUBMIT|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=submit&adv=false&sortby=cm_rnd_rankvalue] a report which use the LDB and get back the data (export/import), by default in the syntax of SUBMIT the selection-screen will not be displayed
    - Use [LDB_PROCESS|https://www.sdn.sap.com/irj/sdn/advancedsearch?query=ldb_process&cat=sdn_all], fill a structured table for selection, and get data back in another table
    - Use [HR function modules to read Infotypes|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=hrfunctionmodulestoread+Infotypes&adv=false&sortby=cm_rnd_rankvalue].
    Regards

  • I want to use Berkely database for my Dissertation

    Hello everyone,
    I am having some doubts regarding Berkely database. Actually, I am using this database for my project. The scenario of the project is, I have developed some business rules depending on the concept of Ripple Down Rules and represented the rules using Conceptual graphs. Now I want to store fire these business rules in to the Berkely database, so that my application can use these business rules from the Berkeley database.
    This is the context of my project. But, I am very new to this Berkely database. I have downloaded the Berkely database from the Oracle website and also installed it. The OS is am using is Windows XP SP2. Can anyone explain me how to store Conceptual graphs in a Berkely database.
    I am really a beginner to Berkely database. i don't even know what to do after installing the Berkely database. Please advise me about this.
    I would be very thankful to you.
    Cheers,
    Phani.

    Hi Phani,
    The simple answer is however you want. Berkeley DB doesn't put any constraints on how you store data in it. Its main purpose is to provide an efficient and scalable key/value storage and retrieval system, upon which you can build your own data storage system.
    More specifically, if you're representing graph data, the simplest way to do so is with the "edge list" paradigm. You could, for example, set up a pair of databases, one to store all your graph nodes (with associated metadata) and one for directed edges. I'm not sure what particular c structures you'll want to use for these, but I'd suggest using record numbers on both the nodes and the edges DBs, unless all your nodes have unique and meaningful names. I'd also allow duplicate records on your edges DB, and have a very simple record structure in it that simply maps from a source node id to a destination node it (the duplicates allow multiple edges from a given node.)
    If you have more specific constraints on your graph and algorithms you'd like to run on it, there are potentially more schemes you could use, such as the nested set representation for trees, and so on.
    Hope this helps,
    Daniel

  • Right way to code an AIR application that uses sqllite database

    I am developing an AIR application that uses sqllite database.I want to know the correct way in which I should create the connections and SQLstatements according to MVC pattern.For example,whether i should have a single SQLStatement object for all my sql operations or I should use separate objects for insert,delete,select etc.I know how to open connection,execute statements and all,but i want to know the professional way of writing it.

    Make a controller for connect to db and save the connection in global varible (in model). Use this connection variable whenever u wanna execute the sql statements. Create seperate dao's for each table. Queries should be executed under the daos. You can call the method under the dao for execute the query from controller and show the result in view.

  • Can we use different Databases (Oracle & SQL Server) in one report?

    Post Author: venki5star
    CA Forum: .NET
    Hi there.
    Can we use different databases (Oracle & SQL Server) in a same report?
    If possible how?
    Another question,
    Can we change the Provider Name at runtime of the given report. If so the above question is useless...
    Thanks in Advance.

    I tried this using Oracle Provider for OLEDB (the one that supplied by Oracle Client) and Crystal Reports 9. you can drag the column into designer but the image does not appear in preview.
    I guess it's because CR does not recognized it as image, and there are no information that the blob data is an image at all.

  • How can I use two database in Dataset in SSRS?

    Hi,
    I am using one query to generate my SSRS report. In that query I am using subquery. Now I am pulling data from multiple tales.
    DB used in sub query is different than the rest of the tables DB.(So total I am using 2 DB(Database))
    So I see that in SSRS, I can connect query(In DataSet Properties) to one DATA_SOURCE only, how can I use other database which is I used in sub-query?
    I have to move this SSRS into PROD and I can't hard code that sub-query's DB name in my query.
    Please give me suggestion. Thanks!!
    Vicky

    In SSRS 2008 R2 you can use the Lookup function (http://technet.microsoft.com/en-us/library/ee210531.aspx ) and LookupSet function (http://technet.microsoft.com/en-us/library/ee240819.aspx
    Depending on your security set up, you can reference a table in a second database on the same server using a three part name:  database.schema.table.  This is more likely to work for you if you wrap your SQL command in a stored procedure.
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • How to host one application using different database connection on OAS?

    Hi,
    Jdeveloper - 10.1.3.4
    Application - ADF/BC
    Oracle Application Server - 10.1.3
    Above our the specifications for our application,
    We have two database schemas different for development and production therfore we have different databse connections for the two,
    we have one application which is in production and enhacements on the same application are done by the development team.
    Since we have two different schemas for developement and prduction we use different database connections for the application on development and production.
    The problem is our Model and View Controller project are same, only the database connection file changes that's why we are able to host only on application at a time on our OAS. This is probably because the URL generated by OAS for developemnt and prodyction application is same.
    Is there a way we can host two instances of the same application with two different database connections on the a single OAS.
    Thanks & Regards,
    Raksha

    Use different deployment profiles each with a different context root for your application?
    See: http://one-size-doesnt-fit-all.blogspot.com/2009/02/configuring-separate-dev-test-prod-urls.html

  • How to use another database schema in Dictionary project

    Problem description:
    1)     I want to use Developer Studio to create my own J2EE project. Then I have to use Dictionary Project to maintain my database.  My database is Oracle.
    2)     I created tables in Dictionary project and deployed to database
    3)     After that I found my tables were deployed into SAPSR3DB schema.
    Question:
          What can I do if I want to deploy my tables into another schema other than SAPSR3DB?  In real cases I want to separate my tables from the WAS system tables.

    Hi Chaoran,
    If you want to use external database with Java dictionary tables..
    Right click on the Java Dictionary Table, from the menu select <b>Create DDL script</b>, then select to which data base you want to generate scripts. It will generate .sql scripts, use this scripts in your database to create tables. But the same time you need to create Data sources in Visual Administrator for your oracle system.
    Regards
    Abhilash

  • How can I delete a row in access using the database toolkit?

    I want to delete just one row of a access table using the database toolkit. Can it be done and if so How?

    Take a look at page A-1 of the database connetivity manual. It has information on making a sql query that will delete. You will need to use this command with the dbtools execute query function. Look in the shipping examples for an example with this function.

  • Not able to create a database link using the database gateway of oracle 11g

    HI,
    While trying to create a database link to SQL server from Oracle ,using the database gateway provided with 11g, i am getting the following error while making use of it in selecting columns from tables :
    Error starting at line 1 in command:
    select * from test1@dblink
    Error at Command Line:1 Column:20
    Error report:
    SQL Error: ORA-28513: internal error in heterogeneous remote agent
    ORA-02063: preceding line from DBLINK
    These are the steps i have followed for setting up:
    1.Ran the set up for the Database gateway.and mentioned the SQL server name and database .ALos set up a listener.
    2. Added the following in the Listener.ora of Oraclehome 11/NETWORK/ADMIN:
    LISTENER_SQL_FCD =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST =localhost) (PORT = 1541)
    SID_LIST_LISTENER_SQL_FCD =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME=dg4msql)
    (ORACLE_HOME= D:\app\20537\product\11.1.0\db_3)
    (PROGRAM=dg4msql)
    3.Added the following in tnsnames.ora inOracle home/NETWORK/ADMIN:
    dg4msql=
    (DESCRIPTION=
    (ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1541))
    (CONNECT_DATA=(SID=dg4msql))
    (HS=OK)
    4. Following is the entry in initdg4msql.ora in C:\product\11.1.0\tg_5\dg4msql\admin:
    HS_FDS_CONNECT_INFO=10.148.45.242:1433//SalesDemo
    HS_FDS_TRACE_LEVEL=DEBUG
    HS_FDS_RECOVERY_ACCOUNT=RECOVER
    HS_FDS_RECOVERY_PWD=RECOVER
    5. Created the database link :
    create database link dblink
    connect to "sa" identified by "<pswd>"
    using 'dg4msql'
    On running :select * from test1@dblink i get the following error:
    Error starting at line 1 in command:
    select * from test1@dblink
    Error at Command Line:1 Column:20
    Error report:
    SQL Error: ORA-28513: internal error in heterogeneous remote agent
    ORA-02063: preceding line from DBLINK
    Is there any issue with the set or definition that I get the above error?

    What is the version of the Oracle database in which you have specified/and use the database link?
    If it is for example 10.2.0.3.0 you need to apply the mandatory patch for RDBMS bug 5965763 first before being able to use an 11g gateway. Have a look at MetaLink note 457808.1 for details about this patch.
    Regards,
    Ed

  • How to generate a single report  using multiple Databases

    Hi All
    Is it possible to create a single report using multiple databases
    I am working on Database A to generate reports usually,, but now i have a second database for which the data is coming from flat files now i have to use few tables from
    Database B to generate a single report,,,,, can any one help with the process

    Hi,
    i didn't see this properly in your post:
    but now i have a second database for which the data is coming from flat files if you have ETL then make flat files as source then create target tables in db:B itself.. .Now, import them in the rpd..
    If not, import both those tables into rpd with different connections..
    Create physical joins by selecting those tables and perform joins operations over db's in physical layer..

  • When using the Database Connectivity Toolset, reads and writes with long binary fields are incompatible.

    I am trying to write LabVIEW Variants to long binary fields in a .mdb file using the Database Connectivity Toolset. I get errors when trying to convert the field back to a variant after reading it back from the database.
    I next tried flattening the variant before writing it and ultimately wound up doing the following experiments:
    1) If I use DB Tools Insert Data to write an ordinary string and read it back using a DB Tools Select Data, the string is converted from ASCII to Unicode.
    2) If I use DB Tools Create Parameterized Query to do an INSERT INTO or an UPDATE operation, specifying that the data is BINARY, then read it back using a DB Tools Select Data,
    the length of the string is prepended to the string itself as a big-endian four-byte integer.
    I can't think of any way to do a parameterized read, although the mechanism exists to return data via parameters.
    Presuming that this same problem affects Variants when they are written to the database and read back, I could see why I get an error. At least with flattened strings I have the option of discarding the length bytes from the beginning of the string.
    Am I missing something here?

    David,
    You've missed the point. When a data item is flattened to a string, the first four bytes of the string are expected to be the total length of the string in big-endian binary format. What is happening here is that preceding this four-byte length code is another copy of the same four bytes. If an ordinary string, "abcdefg" is used in place of the flattened data item, it will come back as <00><00><00><07>abcdefg. Here I've used to represent a byte in hexadecimal notation. This problem has nothing to do with flattening and unflattening data items. It has only to do with the data channel consisting of writing to and reading from the database.
    I am attaching three files that you can use to demonstrate the problem. The VI file c
    ontains an explanation of the problem and instructions for installing and operating the demonstration.
    Ron Martin
    Attachments:
    TestLongBinaryFields.vi ‏132 KB
    Sample.UDL ‏1 KB
    Sample.mdb ‏120 KB

  • Got an error while creating bind variables using sql database.

    iam going to use sql database for ADF-BC .
    i created the bind variable and apply the bind position for the corresponding variable in the view object editor.when i click test it shows me "query is valid". when i tried to run that it gives me two errors.
    1) sql error during statement preparation.(ie) select empid ,empname......from the emptable where empid like :'emp' and
    2) [Microsoft][SQl server  2000 driver  for jDBC] invalid parameter bindings
    i need help to know the solution for this...(or) is there any other way to create bind variable ......

    The 3 binding styles supported by JDev:
    Oracle Named - ie. SELECT xxxx FROM xxxx WHERE emp_id = :vEmp (note colon and variable name)
    Oracle Positional - ie SELECT xxxx FROM xxxx WHERE emp_id = :1 (note colon)
    JDBC Positional - ie SELECT xxxx FROM xxxx WHERE emp_id = ?
    Literally this query is sent to the database to execute, then the bind variables values are applied as a separate database operation. If SQL Server doesn't suport any of these binding styles, it's not going to work. As Chris Noonan suggests, try the JDBC Positional style though as you're using a JDBC driver to connect to SQL Server and it should support that style (the others are Oracle styles), and make sure you've switched the binding style on the VO query page to "JDBC Positional" too.
    You must also on the VO bind variable page define your bind variables.
    Also read the 10.1.3 JDev guide on ADF Business Components and View Object bind variables.
    CM.

  • Creating a new folder using a Database Link

    I'm trying to create a new folder from another database with Discoverer Administrator. The schema that I'm using is the same on each database but when I select the other database using the database link, Discoverer Administrator will get all the user accounts on the other database but if that user exists on the default database I will only see the objects owned for that user on the default database. If I select a user that is only on the remote database I will see the objects from the remote database. Is this a Bug? I was able to do this using Disco Admin 9.0.4 and EUL 5.02 on an Oracle 8i database. I just migrated my EUL to an Oracle 10g database using EUL 5.1.1 and Disco Admin 10.1.2.

    Yes this a bug, Bug No. 4324352 &Note:459996.1
    You follow this workaround
    After the Folder creation
    1. Choose Folder Properties (right-click on Folder)
    2. Change database from <default database> to <DBLINK>
    Thanks
    Mohamed

  • How to retrieve data using logical database and custom select options

    Hi all,
    I have a selection screen which is displayed by logical database PSJ and I have two select options of my own. I need to retrieve data based on both selection screen of logical database and my own select options. How can I do it?
    Thanks in advance.

    Hai Gupta
    Check the following Document & Links
    1. A logical database is in fact
    a program only.
    2. This LDB provides two main things :
    a) a pre-defined selection screen
    which handles all user inputs and validations
    b) pre defined set of data
    based upon the user selection.
    3. So we dont have to worry about from
    which tables to fetch data.
    4. Moreover, this LDB Program,
    handles all user-authorisations
    and is efficient in all respects.
    5. tcode is SLDB
    good info about Logical Database. you can check the link.
    http://www.geekinterview.com/question_details/1506
    http://help.sap.com/saphelp_46c/helpdata/EN/35/2cd77bd7705394e10000009b387c12/frameset.htm
    Re: How to Create and Use ldb in reports?
    Re: Logical databases
    http://help.sap.com/saphelp_46c/helpdata/en/9f/db9bed35c111d1829f0000e829fbfe/frameset.htm
    Functions for displaying and changing logical databases:
    Call Transaction SE36 or
    Choose ABAP Workbench -> Development -> Programming environ. -> Logical databases
    Interaction between database program and report:
    During program processing, subroutines are performed in the database program and events are executed in the report.
    To read data from a database tables we use logical database.
    A logical database provides read-only access to a group of related tables to an ABAP/4 program.
    advantages:-
    The programmer need not worry about the primary key for each table.Because Logical database knows how the different tables relate to each other,and can issue the SELECT command with proper where clause to retrieve the data.
    i)An easy-to-use standard user interface.
    ii)check functions which check that user input is complete,correct,and plausible.
    iii)meaningful data selection.
    iv)central authorization checks for database accesses.
    v)good read access performance while retaining the hierarchical data view determined by the application logic.
    disadvantages:-
    i)If you donot specify a logical database in the program attributes,the GET events never occur.
    ii)There is no ENDGET command,so the code block associated with an event ends with the next event
    statement (such as another GET or an END-OF-SELECTION).
    1. transaction code SLDB.
    2.enter name z<ldb-name>
    3.create
    4.short text
    5.create
    6. name of root node (here Ekko)
    7. enter short text (f6)
    8.node type -> data base table.
    9.create
    10 change logical DB
    riht click on ekko and insert node
    here node name ekpo
    11.create
    12. click on selections
    13. press no Should the changed structure of Z<ldb name> be saved first.
    14.select tables which you want to join.
    15.transfer
    16 now you have to o to coding part.
    17. save
    activate.
    19.click to src code
    double click on first include and activate
    Regards
    Sreeni

  • Cannot use multiple database in my application

    I have written a C++/CLI wrapper for use berkeleydb without lost performance. This wrapper run perfectly with one database but when i open a second database ( i create a new instance of the wrapper ) the application crash.
    I have written a minimal pure C++ application that use the pure C++ classe of my wrapper, when a open and use only one database the code run perfectly but with two databases, the application be crazy.
    infos : compiler VC++ 2008, OS : Vista 32bit
    this the code of my berkeleydb class :
    #pragma comment (lib, "libdb47.lib")
    #if defined(WIN32) || defined(WIN64)
    #include <windows.h>
    #include <list>
    #endif
    #ifndef ParamsStructCpp
    #include "ParamsStruct.h"
    #endif
    #include <db_cxx.h>
    #include "BerkeleyMethods.h"
    using namespace std;
    using namespace stdext;
    // type
    //typedef list<ParamsStructCpp>::iterator it;
    typedef list<ParamsStructCpp> fetchbuffer;
    // Db objects
    Db * db; // Database object
    DbEnv env(0); // Environment for transaction
    u_int32_t oFlags = DB_CREATE|DB_AUTO_COMMIT|DB_READ_UNCOMMITTED; // Open flags; //
    u_int32_t env_oFlags = DB_CREATE |
    DB_THREAD |
                             DB_INIT_LOCK |
                             DB_INIT_LOG |
                             DB_INIT_MPOOL |
                             DB_INIT_TXN |
                             DB_MULTIVERSION; // Flags for environement
    // Constructeurs
    BerkeleyMethods::BerkeleyMethods()
    BerkeleyMethods::BerkeleyMethods(char * dbname, unsigned int db_cache_gbyte, unsigned int db_cache_size,
                        int db_cache_number, int db_type, char * dberr_file, char * envdir, unsigned int dbtxn_timeout,
                             unsigned int dbtxn_max)
         strcpy_s(this->db_name, strlen(_db_name)+1, dbname);
         this->db_cache_gbyte = db_cache_gbyte;
    this->db_cache_size = db_cache_size;
         this->db_cache_number = db_cache_number;
    this->db_type = db_type;
         this->db_txn_timeout = dbtxn_timeout;
         this->db_txn_max = dbtxn_max;
         strcpy_s(this->db_err_file, strlen(_db_err_file)+1, dberr_file);
         strcpy_s(this->env_dir, strlen(_env_dir)+1, envdir);
         this->Set_restoremode(false);
    // ==========
    // Fonctions
    // http://www.codeproject.com/KB/string/UtfConverter.aspx
    bool BerkeleyMethods::OpenDatabase()
         try
              std::cout << "Dbname " << this->db_name << std::endl;
              if (strlen(this->db_name) < 2) {
    throw new std::exception("Database name is unset");
              // Set database cache
              env.set_cachesize(this->db_cache_gbyte, this->db_cache_size, this->db_cache_number);
              // Set transaction timeout
              if (this->db_txn_timeout > 0) {
                   env.set_timeout(this->db_txn_timeout, DB_SET_TXN_TIMEOUT);
    // Set max opened transactions
              if (this->db_txn_max > 0) {
                   env.set_tx_max(this->db_txn_max);
              // Dupplicate key support;
              if (this->Get_dup_support()) {
    env_oFlags = env_oFlags|DB_DUPSORT;
              // Deadlokcs gesture
              env.set_lk_detect(DB_LOCK_MINWRITE);
    // Set the error file
              env.set_errfile(fopen(this->db_err_file, "w+"));
    // Error prefix
              env.set_errpfx("Error > ");
              // Open environement
              env.open(this->env_dir, env_oFlags, 0);
              // Create database object
              db = new Db(&env, 0);
              // Open the database
              switch(this->db_type)
              case 1:
                   db->open(NULL, this->db_name, NULL, DB_BTREE, oFlags, 0);
                   break;
              case 2:
                   db->open(NULL, this->db_name, NULL, DB_HASH, oFlags, 0);
                   break;
              case 3:
                   db->open(NULL, this->db_name, NULL, DB_QUEUE, oFlags, 0);
                   break;
              case 4:
                   db->open(NULL, this->db_name, NULL, DB_RECNO, oFlags, 0);
                   break;
              default:
                   throw new std::exception("Database name is unset");
                   break;
              u_int32_t gbcacheSize = 0;
    u_int32_t bytecacheSize=0;
    int ncache=0;
    env.get_cachesize(&gbcacheSize,&bytecacheSize,&ncache);
    std::cerr << "Taille du cache est:" << gbcacheSize << "Go plus " << bytecacheSize << " octets." << std::endl;
    std::cerr << "Number of caches : " << ncache << std::endl;
              return true;
         catch(DbException &e)
              std::cout << e.what() << std::endl;
         catch(std::exception &e)
              std::cout << e.what() << std::endl;
         return false;
    bool BerkeleyMethods::CloseDatabase()
         try
              db->close(0);
              env.close(0);
              return true;
         catch(DbException &e)
              std::cout << e.what() << std::endl;
         catch(std::exception &e)
              std::cout << e.what() << std::endl;
         return false;
    bool BerkeleyMethods::AddData(char * key, unsigned long int value)
         if (this->Get_restoremode())
              return false;
         DbTxn * txn;
         try
              env.txn_begin(NULL, &txn, 0); // Bebin transaction
              // Set datas
    Dbt _key(key, strlen(key)+1);
    Dbt _value(&value, sizeof(unsigned long int));
              env.txn_checkpoint(512, 2, 0);
              int exist = db->put(txn, &_key, &_value, DB_NOOVERWRITE);
              if (exist == DB_KEYEXIST) {
                   std::cout << "This record already exist" << std::endl;
              txn->commit(0);
              return true;
         catch(DbException &e)
              std::cout << e.what() << std::endl;
              txn->abort();
         catch(...)
              std::cout << "Error" << std::endl;
              txn->abort();
         return false;
    bool BerkeleyMethods::AddData(unsigned long int key, char * value)
         if (this->Get_restoremode())
              return false;
         DbTxn * txn;
         try
              env.txn_begin(NULL, &txn, 0); // Bebin transaction
    Dbt _key(&key, sizeof(unsigned long int));
              Dbt _value(value, strlen(value)+1);
              env.txn_checkpoint(512, 2, 0);
              int exist = db->put(txn, &_key, &_value, DB_NOOVERWRITE);
              if (exist == DB_KEYEXIST) {
                   std::cout << "This record already exist" << std::endl;
              txn->commit(0);     
              return true;
         catch(DbException &e)
              std::cout << e.what() << std::endl;
              txn->abort();
         catch(...)
              txn->abort();
         return false;
    bool BerkeleyMethods::AddData(char * key, char * value)
         if (this->Get_restoremode())
              return false;
         DbTxn * txn;
         try
              env.txn_begin(NULL, &txn, 0); // Bebin transaction
    Dbt _key(key, strlen(key)+1);
              Dbt _value(value, strlen(value)+1);
              env.txn_checkpoint(512, 2, 0);
              int exist = db->put(txn, &_key, &_value, DB_NOOVERWRITE);
              if (exist == DB_KEYEXIST) {
                   std::cout << "This record already exist" << std::endl;
              txn->commit(0);     
              return true;
         catch(DbException &e)
              std::cout << e.what() << std::endl;
              txn->abort();
         catch(...)
              txn->abort();
         return false;
    bool BerkeleyMethods::AddData(unsigned long int key, unsigned long int value)
         if (this->Get_restoremode())
              return false;
         DbTxn * txn;
         try
              env.txn_begin(NULL, &txn, 0); // Bebin transaction
    Dbt _key(&key, sizeof(unsigned long int));
              Dbt _value(&value, sizeof(unsigned long int));
              env.txn_checkpoint(512, 2, 0);
              int exist = db->put(txn, &_key, &_value, DB_NOOVERWRITE);
              if (exist == DB_KEYEXIST) {
                   std::cout << "This record already exist" << std::endl;
              txn->commit(0);     
              return true;
         catch(DbException &e)
              std::cout << e.what() << std::endl;
              txn->abort();
         catch(...)
              txn->abort();
         return false;
    bool BerkeleyMethods::AddData(char * key, ParamsStructCpp value)
         if (this->Get_restoremode())
              return false;
         DbTxn * txn;
         try
              env.txn_begin(NULL, &txn, 0); // Bebin transaction
    Dbt _key(key, strlen(key)+1);
              Dbt _value(&value, sizeof(ParamsStructCpp));
              env.txn_checkpoint(512, 2, 0);
              int exist = db->put(txn, &_key, &_value, DB_NOOVERWRITE);
              if (exist == DB_KEYEXIST) {
                   std::cout << "This record already exist" << std::endl;
              txn->commit(0);     
              return true;
         catch(DbException &e)
              std::cout << e.what() << std::endl;
              txn->abort();
         catch(...)
              txn->abort();
         return false;
    bool BerkeleyMethods::AddData(unsigned long int key, struct ParamsStructCpp value)
         if (this->Get_restoremode())
              return false;
         DbTxn * txn;
         try
              env.txn_begin(NULL, &txn, 0); // Bebin transaction
    Dbt _key(&key, sizeof(unsigned long int));
              Dbt _value(&value, sizeof(ParamsStructCpp));
              env.txn_checkpoint(512, 2, 0);
              int exist = db->put(txn, &_key, &_value, DB_NOOVERWRITE);
              if (exist == DB_KEYEXIST) {
                   std::cout << "This record already exist" << std::endl;
              txn->commit(0);     
              return true;
         catch(DbException &e)
              std::cout << e.what() << std::endl;
              txn->abort();
         catch(...)
              txn->abort();
         return false;
    bool BerkeleyMethods::Exist(unsigned long int key)
         if (this->Get_restoremode())
              return true;
         DbTxn * txn;
         try
              env.txn_begin(NULL, &txn, DB_TXN_SNAPSHOT); // Bebin transaction
    Dbt _key(&key, sizeof(unsigned long int));
              int state = db->exists(txn, &_key, DB_READ_COMMITTED);
              txn->commit(0);
              if (state == 0) {
                   return true;
         catch(DbException &e)
              std::cout << e.what() << std::endl;
              txn->abort();
         catch(...)
              txn->abort();
         return false;
    bool BerkeleyMethods::Exist(char * key)
         if (this->Get_restoremode())
              return true;
         DbTxn * txn;
         try
              env.txn_begin(NULL, &txn, DB_TXN_SNAPSHOT); // Bebin transaction
              Dbt _key(key, strlen(key)+1);
              int state = db->exists(txn, &_key,DB_READ_COMMITTED);
              txn->commit(0);
              if (state == 0) {
                   return true;
         catch(DbException &e)
              std::cout << e.what() << std::endl;
              txn->abort();
         catch(...)
              txn->abort();
         return false;
    void BerkeleyMethods::GetData (char * pData, int nbr, unsigned long int key)
         if (this->Get_restoremode())
              return;
         DbTxn * txn;
         Dbc *dbcp;
         try
    env.txn_begin(NULL, &txn, DB_TXN_SNAPSHOT); // Bebin transaction
              db->cursor(txn, &dbcp, 0);
              Dbt _key;
              Dbt data;
              key.setdata(&key);
              key.setsize(sizeof(unsigned long int));
              dbcp->get(&_key, &data, DB_FIRST);
              char * temp = (char *)data.get_data();
    strcpy_s(pData, strlen(temp)+1, temp);
              dbcp->close();
              txn->commit(0);
         catch(DbException &e)
              std::cout << e.what() << std::endl;
              if (dbcp != NULL)
                   dbcp->close();
              if (txn != NULL)
                   txn->abort();
         catch(...)
              if (dbcp != NULL)
                   dbcp->close();
              if (txn != NULL)
                   txn->abort();
    unsigned long int BerkeleyMethods::GetData(char * key)
         if (this->Get_restoremode())
              return 0;
         DbTxn * txn;
         Dbc *dbcp;
         try
    env.txn_begin(NULL, &txn, DB_TXN_SNAPSHOT); // Bebin transaction
              db->cursor(txn, &dbcp, 0);
    Dbt _key;
              Dbt data;
              key.setdata(key);
              key.setulen(strlen(key)+1);
              dbcp->get(&_key, &data, DB_FIRST);
    unsigned long int xdata = *((unsigned long int *)data.get_data());
              dbcp->close();
              txn->commit(0);
              return xdata;
         catch(DbException &e)
              std::cout << e.what() << std::endl;
              dbcp->close();
              txn->abort();
         catch(...)
              dbcp->close();
              txn->abort();
         return 0;
    ParamsStructCpp * BerkeleyMethods::GetData(unsigned long int key, bool null)
         if (this->Get_restoremode()) {
              return new ParamsStructCpp();
         DbTxn * txn;
         Dbc *dbcp;
         try
    env.txn_begin(NULL, &txn, DB_TXN_SNAPSHOT); // Bebin transaction
              db->cursor(txn, &dbcp, 0);
              Dbt _key;
              Dbt data;
              key.setdata(&key);
              key.setsize(sizeof(unsigned long int));
    dbcp->get(&_key, &data, DB_FIRST);
              ParamsStructCpp * temp = (ParamsStructCpp *)data.get_data();
              dbcp->close();
              txn->commit(0);
              return temp;
         catch(DbException &e)
              std::cout << e.what() << std::endl;
              dbcp->close();
              txn->abort();
         catch(...)
              dbcp->close();
              txn->abort();
         return new ParamsStructCpp();
    ParamsStructCpp * BerkeleyMethods::GetData(char * key, bool null)
         if (this->Get_restoremode()) {
              return new ParamsStructCpp();
         DbTxn * txn;
         Dbc *dbcp;
         try
    env.txn_begin(NULL, &txn, DB_TXN_SNAPSHOT); // Bebin transaction
              db->cursor(txn, &dbcp, 0);
    Dbt _key;
              Dbt data;
              key.setdata(key);
              key.setulen(strlen(key)+1);
              dbcp->get(&_key, &data, DB_FIRST);
    ParamsStructCpp * xdata = (ParamsStructCpp *)data.get_data();
              dbcp->close();
              txn->commit(0);
              return xdata;
         catch(DbException &e)
              std::cout << e.what() << std::endl;
              dbcp->close();
              txn->abort();
         catch(...)
              dbcp->close();
              txn->abort();
         return new ParamsStructCpp();
    list<ParamsStruct> BerkeleyMethods::FetchAllDatabase ()
         list<ParamsStruct> temp;
         Dbc *dbcp;
         try
              db->cursor(NULL, &dbcp, 0);
    Dbt _key;
              Dbt data;
    while(dbcp->get(&_key, &data, DB_NEXT))
                   unsigned long int key = *((unsigned long int *)_key.get_data());
                   char * datetime = (char *)data.get_data();
                   ParamsStruct p;
                   strcpy_s(p.lastaccess, strlen(datetime)+1, datetime);
                   p.downloaded
                   temp.push_back(
                   //temp.insert(Tuple(datetime, key));
         catch(DbException &e)
              std::cout << e.what() << std::endl;
         catch(...)
         return temp;
    bool BerkeleyMethods::DeleteData(unsigned long int key)
         if (this->Get_restoremode())
              return true;
         DbTxn * txn;
         try
              env.txn_checkpoint(128, 1, 0);
              env.txn_begin(NULL, &txn, 0); // Bebin transaction
    Dbt _key;
              key.setdata(&key);
              key.setsize(sizeof(unsigned long int));
              db->del(txn, &_key, 0);
              txn->commit(0);
              return true;
         catch(DbException &e)
              std::cout << e.what() << std::endl;
              txn->abort();
         catch(...)
              txn->abort();
         return false;;
    bool BerkeleyMethods::DeleteData(char * key)
         if (this->Get_restoremode())
              return true;
         DbTxn * txn;
         try
              env.txn_begin(NULL, &txn, 0); // Bebin transaction
    Dbt _key;
              key.setdata(key);
              key.setulen(strlen(key)+1);
              db->del(txn, &_key, 0);
              txn->commit(0);
              return true;
         catch(DbException &e)
              std::cout << e.what() << std::endl;
              txn->abort();
         catch(...)
              txn->abort();
         return false;
    int BerkeleyMethods::Sync()
         if (this->Get_restoremode())
              return -1;
         try
              return db->sync(0);
         catch(...)
    return -1;
    int BerkeleyMethods::Count()
         if (this->Get_restoremode())
              return -1;
         Dbc *dbcp;
         int count = 0;
         try
    Dbt key;
              Dbt data;
              db->cursor(NULL, &dbcp, 0);
              while (dbcp->get(&key, &data, DB_NEXT) == 0) {
    count++;
              dbcp->close();
              return count;
         catch(...)
    return -1;
    BerkeleyMethods::~BerkeleyMethods()
         if (db) {
         db->sync(0);
    db->close(0);
         env.close(0);
    =====
    The code the use this class :
         BerkeleyMethods db("test.db", 0, 524288000, 1, 1, "log.txt", "./Env_dir", 1000000 * 5, 600000);
                   BerkeleyMethods db1("test2.db", 0, 524288000, 1, 1, "log2.txt", "./Env_dir2", 1000000 * 5, 600000);
    bool z = db.OpenDatabase();
    db1.OpenDatabase();
    if (z)
                        std::cout << "Base de données ouverte" << std::endl;
                   for (unsigned int i = 0; i < 1000; i++)
                        ParamsStructCpp p = { 10, "02/08/2008 14:46:23", 789 };
                   bool a = db.AddData(i, p);
                        db1.AddData(i, p);
    if (a)
                        std::cout << "Ajout de données ok" << std::endl;
                   for (unsigned int i = 0; i < 1000; i++)
                        ParamsStructCpp * c = db.GetData(i, false);
                        ParamsStructCpp * c1 = db1.GetData(i, false);
                        std::cout << "Donné récupéré " << c->downloaded << " : " << c->lastaccess << " : " << c->waittime << std::endl;
                        std::cout << "Donné récupéré " << c1->downloaded << " : " << c1->lastaccess << " : " << c1->waittime << std::endl;
    / ====
    The application output show that when using two database the data is not correctly set. It seems that db and db1 is the same object :|.
    For example in db i insert a key => toto with value 4, and in db1 i insert the same value nomaly have no problem. But berkeleydb say the the key toto in db1 already exist while not
    I don't understand.
    NB : sorry for my english

    Michael Cahill wrote:
    As a side note, it is unlikely that you want both
    DB_READ_UNCOMMITTED and DB_MULTIVERSION to be set.
    This combination pays a price during updates for
    maintaining multiple versions, but still requires
    (short term) locks to be held during reads. The BDB/XML Transaction Processing Guide states the following:
    [...]in addition to BDB XML's normal degrees of isolation, you can also use snapshot isolation. This allows you to avoid the read locks that serializable isolation requires.
    http://www.oracle.com/technology/documentation/berkeley-db/xml/gsg_xml_txn/cxx/isolation.html
    This seems to contradict what you're saying here.
    Is there a general guideline on whether or not to use MVCC together with a relaxed isolation degree like DB_READ_UNCOMMITTED? Should the statement in the BDB/XML TP Guide rather have "as an alternative to" instead of "in addition to"?
    Michael Ludwig

Maybe you are looking for

  • Pass parameter from page link to report

    <span><font face="Verdana, Geneva, Arial, Sans-serif" size="2">How can I pass 3 parameter values from a link on one page to a report or CrystalReportViewer.<br /><br />Report is a CR/VS 2005 web report in C#<br /><br />Parameter fields in the report

  • Assigning a value to a Constant

    I have OWB 10..0.1.31 on XP as Client installed. I want to assign a value to a constant; I did the following: Picking the Constant from the toolbox->assigned a name to the constant ->added an attribute to the outputgroup, the name is TODAY DATE; I th

  • Purchase order delivery shedule tabl , no Good issue date, loading date.?

    Hi Experts   We found some Purchase order, in po item, it is without goods issue date, loading date and so on. Material has set ATP check on mrp3. what's possbile wrong? something wrong for matieral setup or others? Thanks Alice

  • Can't use ch340g serial port driver since upgrading to Yosemite on MacBook air

    I use my MacBook air with the Arduino 1.0.6 IDE. Since upgrading ( free upgrade) to Yosemite. I can no longer acess the ch340g serial port. (does not show up in arduino ide). I tried re-installing the driver. I get no errors and am told the install w

  • Query run in Sql prompt correctly but give error in APEX report ORA-01843

    Hi. all APEX user Last week I upgrade APEX 3.2 to 4.0.2 . Now i have a problem. PL/SQL reports which are working in APEX 3.2 not working in 4.0.2. Help me..... I am working on a mission critical application we have to upgrade there next month. Query