Physical file of the "Database" object keep growing

Hello,
My Application is using BDB. Version 4.3.29.
We are using the Database object for saving our byte array data to BDB(see the code below)
The written data is initialized by: Byte[] Data = new byte[size].
And we always use the same key for the insert operation. By the BDB API it should overwrite the existing entry, correct me if I’m wrong)
The data size may vary, I.e. it can grow, or decrease.
After monitoring the physical file that sits on dist, we have noticed that the physical file only grows, but never decrease its size. Even when the written data is of a 0 length.
Please explain the issue. What are we doing wrong? Or what additional parameters should be used in order for the phisical file to change its size.i.e. decrease it.
Thank you in advance.
Shira Faigenbaum
Opening the BDB:
DataBase m_dataBase = m_DBEnv().openDatabase(transaction, tablePath + File.separator + m_name, null, m_DatabaseConfig);
The code that we have, for the PUT operation:
DatabaseEntry keyDbt = new DatabaseEntry(new byte[4]);
keyDbt.setSize(4);
keyDbt.setUserBuffer(4, true);
keyDbt.setRecordNumber(DATA_KEY);
DatabaseEntry dataDbt = new DatabaseEntry(data);
dataDbt.setSize(data.length);
dataDbt.setUserBuffer(length, true);
synchronized (transaction)
m_dataBase.put(transaction.getTransaction(), keyDbt, dataDbt);
}

Hi,
There is a bit a lot of code, but here is the program.
thanks
Shira
public class BDBsizeNotReducingExxample
     Environment m_dbEnv;
     private Database m_dataBase = null;
     private byte[] m_serializationBuffer = new byte[256];
     private Object m_data = null;
     public static void main(String[] args)
          BDBsizeNotReducingExxample DbsizeNotReducingExxample = new BDBsizeNotReducingExxample();
          DbsizeNotReducingExxample.opendbEnv();
          DbsizeNotReducingExxample.openDB();
          DbsizeNotReducingExxample.saveData();
     private void opendbEnv()
          try
               EnvironmentConfig ec = new EnvironmentConfig();
               ec.setCacheSize(16 * 1024 * 1024);
ec.setErrorStream(new LogOutputStream());
ec.setVerboseDeadlock(true);
               ec.setVerboseWaitsFor(true);           
ec.setVerboseRecovery(true);      
          ec.setMaxLockers(1024);
               ec.setMaxLocks(100000);                ec.setMaxLockObjects(100000);               ec.setTxnMaxActive(20);
               ec.setLogRegionSize(600 * 1024);     
ec.setLockDetectMode(LockDetectMode.DEFAULT);
ec.setAllowCreate(true);
               ec.setTransactional(true);
          ec.setRunRecovery(true);          ec.setInitializeCache(true);
               ec.setInitializeLocking(true);     ec.setInitializeLogging(true);
               File f = new File("/Application/Persistency");
               //open the environment try to open data base without fatal recovery
               try
                    m_dbEnv = new Environment(f, ec);
               catch (RunRecoveryException dbrre_1)
                    ec.setRunFatalRecovery(true);
                    m_dbEnv = new Environment(f, ec);
               //archive and checkpoint at gatherer start up
               CheckpointConfig cpc = new CheckpointConfig();
               cpc.setForce(true);
               m_dbEnv.checkpoint(cpc);
          catch (Exception e)
               PersistencyUtils.handleFatalException(e);
     private class LogOutputStream extends OutputStream
          public void write(int b) throws IOException
               //some clss just to print the errors
     private void openDB()
          DatabaseEntry keyDbt = new DatabaseEntry(new byte[4]);
     keyDbt.setSize(4);
     keyDbt.setUserBuffer(4, true);
     keyDbt.setRecordNumber(0);
     DatabaseEntry dataDbt = new DatabaseEntry();
     dataDbt.setReuseBuffer(false);
try
     String tablePath = "/Application/Persistency/";
     DirUtil.mkdirs(new File(tablePath));
     PersistencyUtils.verifyFreeDiskSpace();
Transaction transaction = m_dbEnv.beginTransaction(null, null);
//DatabaseConfig use btree
m_dataBase = m_dbEnv.openDatabase(transaction, tablePath + "/Data", null, PersistencyUtils.getDatabaseConfig());
if (m_dataBase.get(transaction, keyDbt, dataDbt, null) != OperationStatus.SUCCESS)
     dataDbt = null;
transaction.commit();
catch (Exception e)
     PersistencyUtils.handleFatalException(e);
if (dataDbt != null)
     byte[] data = dataDbt.getData();
     if (data != null)
          m_serializer.deserialize(m_data, data, 0, data.length);
private void saveData()
int length = m_serializer.serialize(m_data, m_serializationBuffer, 0);
//this function changes the size of the m_serializationBuffer, increase and decrease its size!!!
adjustSerializationBufferToTheRealLength(m_serializationBuffer, length);
DatabaseEntry keyDbt = new DatabaseEntry(new byte[4]);
keyDbt.setSize(4);
keyDbt.setUserBuffer(4, true);
keyDbt.setRecordNumber(0);
DatabaseEntry dataDbt = new DatabaseEntry(m_serializationBuffer);
dataDbt.setSize(length);
dataDbt.setUserBuffer(length, true);
synchronized (currentTransaction)
     m_dataBase.put(transaction.getTransaction(), keyDbt, dataDbt);
}

Similar Messages

  • Insert PDF or Doc file to the Database from Frontend

    Hi
    I am in ISB company working with Oracle 9iDS. The scenario is to me that I would like to insert some document files(especially Pdf formated files) to the database.
    I can use Read_Image_file. but that is used for the image file to bring the image file from physical location to my application, how it is for PDF?
    and how can i save it in the database?
    thanks
    farhad

    So are you saying you want to load a file from the pc/client to the database - then you can use webutil.
    see otn.oracle.com/products/forms
    Regards
    Grant Ronald
    Forms Product Management

  • Store and Display doc/pdf files in the database using Forms

    Hi all,
    How can i store and display doc/pdf files in the database using Forms 10g?.
    Arif

    How to get up and running with WebUtil 1.06 included with Oracle Developer Suite 10.1.2.0.2 on a win32 platform
    Solution
    Assuming a fresh "Complete" install of Oracle Developer Suite 10.1.2.0.2,
    here are steps to get a small test form running, using WebUtil 1.06.
    Note: [OraHome] is used as an alias for your real oDS ORACLE_HOME.
    Feel free to copy this note to a text editor, and do a global find/replace on
    [OraHome] with your actual value (no trailing slash). Then it is easy to
    copy/paste actual commands to be executed from the note copy.
    1) Download http://prdownloads.sourceforge.net/jacob-project/jacob_18.zip
      and extract to a temporary staging area. Do not attempt to use 1.7 or 1.9.
    2) Copy or move jacob.jar and jacob.dll
      [JacobStage] is the folder where you extracted Jacob, and will end in ...\jacob_18
         cd [JacobStage]
         copy jacob.jar [OraHome]\forms\java\.
         copy jacob.dll [OraHome]\forms\webutil\.
      The Jacob staging area is no longer needed, and may be deleted.
    3) Sign frmwebutil.jar and jacob.jar
      Open a DOS command prompt.
      Add [OraHome]\jdk\bin to the PATH:
         set PATH=[OraHome]\jdk\bin;%PATH%
      Sign the files, and check the output for success:
         [OraHome]\forms\webutil\sign_webutil [OraHome]\forms\java\frmwebutil.jar
         [OraHome]\forms\webutil\sign_webutil [OraHome]\forms\java\jacob.jar
    4) If you already have a schema in your RDBMS which contains the WebUtil stored code,
      you may skip this step. Otherwise,
      Create a schema to hold the WebUtil stored code, and privileges needed to
      connect and create a stored package. Schema name "WEBUTIL" is recommended
      for no reason other than consistency over the user base.
      Open [OraHome]\forms\create_webutil_db.sql in a text editor, and delete or comment
      out the EXIT statement, to be able to see whether the objects were created witout
      errors.
      Start SQL*Plus as SYSTEM, and issue:
         CREATE USER webutil IDENTIFIED BY [password]
         DEFAULT TABLESPACE users
         TEMPORARY TABLESPACE temp;
         GRANT CONNECT, CREATE PROCEDURE, CREATE PUBLIC SYNONYM TO webutil;
         CONNECT webutil/[password]@[connectstring]
         @[OraHome]\forms\create_webutil_db.sql
         -- Inspect SQL*Plus output for errors, and then
         CREATE PUBLIC SYNONYM webutil_db FOR webutil.webutil_db;
      Reconnect as SYSTEM, and issue:
         grant execute on webutil_db to public;
    5) Modify [OraHome]\forms\server\default.env, and append [OraHome]\jdk\jre\lib\rt.jar
      to the CLASSPATH entry.
    6) Start the OC4J instance
    7) Start Forms Builder and connect to a schema in the RDBMS used in step (4).
      Open webutil.pll, do a "Compile ALL" (shift-Control-K), and generate to PLX (Control-T).
      It is important to generate the PLX, to avoid the FRM-40039 discussed in
      Note 303682.1
      If the PLX is not generated, the Webutil.pll library would have to be attached with
      full path information to all forms wishing to use WebUtil. This is NOT recommended.
    8) Create a new FMB.
      Open webutil.olb, and Subclass (not Copy) the Webutil object to the form.
      There is no need to Subclass the WebutilConfig object.
      Attach the Webutil.pll Library, and remove the path.
      Add an ON-LOGON trigger with the code
             NULL;
      to avoid having to connect to an RDBMS (optional).
      Create a new button on a new canvas, with the code
             show_webutil_information (TRUE);
      in a WHEN-BUTTON-PRESSED trigger.
      Compile the FMB to FMX, after doing a Compile-All (Shift-Control-K).
    9) Under Edit->Preferences->Runtime in Forms Builder, click on "Reset to Default" if
      the "Application Server URL" is empty.
      Then append "?config=webutil" at the end, so you end up with a URL of the form
          http://server:port/forms/frmservlet?config=webutil
    10) Run your form.sarah

  • How to import an .csv file into the database?

    and can we code the program in JSP to import the.csv file into the database.

    It is better to use Java class to read the CSV file and store the contents in the database.
    You can use JSP to upload the CSV file to the server if you want, but don't use it to perform database operations.
    JSPs are good for displaying information on the front-end, and for displaying HTML forms, there are other technologies more suitable for the middle layer, back end and the database layer.
    So break you application into
    1) Front end - JSPs to display input html forms and to display data retrieved from the database.
    2) Middle layer - Servlets and JavaBeans to interact with JSPs. The code that reads the CSV file to parse it's contents should be a Java Class in the middle layer. It makes use of Java File I/O
    3) Database layer - Connects to the database using JDBC (Java Database Connectivity), and then writes to the database with SQL insert statements.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Keeping the above concepts in mind, first build a simple JSP and get it to work,
    then research on Google , for Java File I/O , discover how to read a file,
    Then search on how to readh a CSV file using Java.
    After researching you should be able to read the CSV file line by line and store each line inside a Collection.
    Then research on Google, on how to write to the database using JDBC
    Write a simple program that inserts something to a dummy table in the database.
    Then, read the data stored in the Collection, and write insert statements for each records in the collection.

  • Store xml files in the database like Microsoft Access

    Dear friends,
    I have come up here with a problem. I have to insert xml files in the database like Microsoft Access.
    So would somebody help me out.
    The query syntax to insert file and then retreive it back from database.
    How would u do it with picture files?
    I am waiting for your help.
    Thanks in advance.
    Yours Truly,
    Khawaja Salman Sarfraz

    Large files are usually stored as binary large objects (BLOBS.) I think MS Access calls these Memo fields.

  • I have a problem with my iPad, the "other" part of the capacity summary keeps growing like ****

    Dear all: I have a problem with my iPad, the "other" part of the capacity summary keeps growing like ****, every time I sync the iPad gets bigger and bigger. What is this "other" and what do I do to keep it from getting bigger? Thanks to all!

    Marcos,
    I did not try your trick, didn't see your post until after i visited the Apple store.  The tech at the genius bar did not know why my "Other" memory had grown so huge.  It was over 24GB, which only left me with 1 GB free on my 32GB iPad.   I had been loading and unloading video's yesterday thru itunes to try various compression settings.  I did not notice the other categrory growing until I tried to load a 3 GB movie file and it told me I was out of memory.
    I probably loaded and unloaded 30 different times, trying different compression settings.  In the process of doing this, it apparently loaded up the "Other: stuff.  To me it seems like recycle bin in windows, but no one knows how to free it up. 
    So here is what he did and it worked.  He reset the iPad.  Press and hold both the Sleep/Wake button and the Home button for at least ten seconds, until the Apple logo appears.  Then he hooked it up to itunes on his computer.  Fortunately I have everything backed up on my home computer.  When my iPad showed up on iTunes at the store, it showed the 24 MB of "Other" momentarily, then it reduced to about .7 GB giving me 24.5 GB free.  Resetting it seemed to do the trick, but he still could tell me how this is happening and how to prevent it. 
    I think I'll try to call someone at applecare to get an explanation, hopefully.

  • SQL Server 2012 Management Studio: How to install AdventureWorks2012_Data.mdf file to the Databases of my SQLEXPRESS?

    Hi All,
    I just downloaded AdventureWorks2012_Data.mdf file from
    http://msftdbprodsamples.codeplex.com/releases/view/55330 to my C:/ Downloads folder.  I don't know how to install this AdventureWorks2012_Data.mdf file to the Databases (in Object Explorer) of the \SQLEXPRESS of my SQL Server 2012 Management
    Studio.  Please kindly help, advise and respond.
    Thanks in advance,
    Scott Chang

    Hi Olaf Helper, Thanks for your response.
    As you  and https//msdn.microsoft.com/en-us/library/ms190209.aspx instructed, I tried to attach the AdventureWorks2012_Data.mdf file (Using SQL Server Management Studio) to my Databses. After I did Steps 1 & 2, (in Step 3) I clicked on
    Add, and tried to locate the AdventureWorks2012_Data.mdf file in my C:/Users/e1enxshc/Downloads folder: this mdf file was not there in the "Select the file" box!!!??? I am pretty sure that mdf file has been downloaded into that "Downloads"
    folder.  I am lost completely.  Please kindly help, advise me what it is going wrong in my "Attach" the mdf file to my Databases of SQLEXPRESS, and respond.
    Thanks,
    Scott Chang
    ===============================================
    Hi Prashanth,
    I cannot find/locate the
    http://serverintellect.com/sqlserver/sql-database-attach/ in my internet websites to do the "Attach" task I need badly. Please tell me where I can find/locate/access that website>
    Thanks,
    Scott Chang
    ==================================================== 
    P.S. I moved the AdventureWorks2012_Data.mdf file to my C:\Temp folder and did the "Add" again. It located the mdf file. I added the AdventureWorks as the name of Database in SQLEXPRESS, then I clicked Add. I got the following fatalerror:
    Failed to retrieve data for this request. (Micosoft....)
    ADDITIONAL INFORMATION:    mICROSOFT sql sERVER, eRROR:5123).
    wHY DOES IT NOT WORK EITHER? 

  • Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the rows? Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the records?
    Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    The Oracle documentation has a good overview of the options available
    Generating XML Data from the Database
    Without knowing your version, I just picked 11.2, so you made need to look for that chapter in the documentation for your version to find applicable information.
    You can also find some information in XML DB FAQ

  • Pulling a PDF file from the database

    How would I display a pdf file from the database, or should I convert it to an image and if so how do I convert it into an image?

    Hi Phil_Kenya,
    Some samples here:
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/db1556be-0f71-41cb-92de-b95f1e1ca3a3/how-can-i-load-a-pdf-file-in-my-database-filemdf-in-aspnet-web-project?forum=csharpgeneral
    http://stackoverflow.com/questions/7747796/displaying-pdf-files-in-a-web-page-from-a-sql-database-directly-without-needing
    I suggest you post this issue to the language development forum like above case, I think you would get more dedicated support.
    Best Regards,
    Jack
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Which is better? store files in the database or directly on the O.S.?

    Hi,
    i´m developing an application to manager files. which is better? store files in the database or directly on the O.S.? If i decide to store on database, i will use the BLOB data type but i have a doubt...the BLOB data type occupies the same space on database regardless of file size? there is another data type better?
    Tks,
    Fernando.

    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1011065100346196442
    Ask Tom has a bit of info to share on the topic. Have a read of this. :)

  • What is the Table/View name for getting the Database Object Dependencies

    I am running the Database Object Dependencies report to get the reference of Database Object and their respective Application Component.
    Applications xxxx -> Application Reports -> Shared Components -> Database Object Dependencies -> Compute Dependencies
    I want to develop a report for the same purpose, Just want to know what is the APEX Tables / Views they are using to run this report, so that I can use the same Tables to create my own report.
    Thanks,
    Deepak

    Hi Andy,
    when I am using the following query...I am not getting any result...
    select name, type, owner
    from all_dependencies
    where referenced_owner = 'APEX_030200'
    and referenced_name = 'WWV_FLOW_PATCHES'
    AND OWNER= 'XXXXXXX' --- (addeed this to the where clause)
    I modified the query.....I am getting the result.....
    select name, type, owner
    from all_dependencies
    AND OWNER= 'XXXXXXX'
    - But I am not getting which database object(table/view) is using which Application Page/Component like we have in Database Object Dependencies.
    - Also what is this REFERENCE OWNER & REFERENCE_NAME ----
    referenced_owner = 'APEX_030200'
    and referenced_name = 'WWV_FLOW_PATCHES'
    I am little bit confused, Can you pl expalin me in details......
    Thanks,
    Deepak

  • Can change the size of the redolog files while the database is running.

    How the size of the redolog files will hurt your database performance ?
    Can change the size of the redolog files while the database is running in oracle 9i. ?
    What will be its impact on the standby database ?
    Thanks in advance.

    redo logs that are too small can cause waits on the switches for heavily utilized systems. logs that are too large are a pain the a$$ during recovery. check v$loghist to see how often switches occur - an average of 20 minutes is good; if you have many switches happening back-to-back, that's a bad sign.
    you can change the sizes while the db is up. choose a redo group that is INACTIVE, drop it, delete the files, and recreate it with larger files. then force a switch ("alter system switch logfile;"), and do another inactive group. I actually prefer to do as many switches as necessary to make the new group active so I can verify that I didn't screw up before dropping the next group.
    not sure of impact on standby database.

  • Storing a ZIP file to the database

    I have to store a zip file to the database. I used ZipOutputStream to compress the data into the Zip format and then insert into the Database.
    This is what i am doing:
    java.sql.PreparedStatement pst = null;
    GZIPOutputStream out_stream = null;
    try
    out_stream =
    new GZIPOutputStream( new ByteArrayOutputStream( reqdata.length() ) );
    FileOutputStream fstr = new FileOutputStream( "file1" );
    ObjectOutputStream obst = new ObjectOutputStream( fstr );
    obst.writeObject( out_stream );
    obst.close();
    FileInputStream in = new FileInputStream( "file1");
    ObjectInputStream in_stream = new ObjectInputStream(in);
    pst.setBinaryStream( 3, in_stream, reqdata.length() );
    in_stream.close();
    catch( Exception e )
    reqdata is the data that i want to store, which i m reading from a file at present.
    It fails at obst.writeObject( out_stream ); coz the GZIPOutputStream is not serializable.
    This data(ZIP file) has to be again read from the database.
    Can someone please help me with this or let me know if there is any other way to do the same
    Thanks in advance

    Just drop the business with the ObjectOutputStream and ObjectInputStream. They would be unnecessary and time-wasting even if they did work.

  • My other section on the sync section keeps growing is there a way to shrink it?

    My other section on the sync section keeps growing is there a way to shrink it?

    I've tried to restore it a few times but it still jumps up to over a GB
    It usually jumps up after I do the the on the actual ipod then jumps again when I add stuff
    to my Ipod

  • Planning the physical layout of the database

    Our application keeps very large historical data for 1 year. We do not use the Partitioning Option but have created 12 different BIG TABLES,
    one for each month. We are wondering if for performance reason or any other reason, whether it is better to put all the tables
    into 2 physical file as show in option 1 or 24 physical files in option 2. Reason for option 2 is to reduce the size of the physical
    files so that we can speed up the backup process by selecting individual files to backup on a monthly basis.
    Does Oracle have any problem with creating too many Table Spaces and physical data files?
    Option 1 - 2 physical data file
    HISTDATA Table Space
    HISTINDEX Table Space
    Option 2 - 24 physical data files
    JANDATA Table Space
    JANINDEX Table Space
    FEBDATA Table Space
    FEBINDEX Table Space
    MARDATA Table Space
    MARINDEX Table Space
    DECDATA Table Space
    DECINDEX Table Space

    From a performance standpoint, it will only have an effect if the different layouts allow you to utilize more disks or to spread the work more evenly among disks. If you have 10 different mount points on 10 different sets of disks, you would probably want files to be spread across all the mountpoints. If you have a SAN where everything is striped and mirrored, it doesn't make a difference.
    From a managability and a backup and recovery standpoint, multiple tablespaces seem most appropriate, particularly since 11 of the 12 months can presumably be marked read-only and excluded from the backup.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

Maybe you are looking for

  • How do I use my Airport Express as my router's bridge to the Internet?

    Howdy! My apartment building recently got wifi.  I want to set up my own wifi network in my apartment so I can connect my MacBook Pro, a wireless printer, and another wifi enabled computer.  I want to be able to print wirelessly, and get on the Inter

  • Multi language pack for Design CS6?

    Is there a multi language pack for Design CS6 available? I installed it in german, but I need it in english.

  • FileNotFound error when trying to launch jnlp

    This seems to be a common issue, however after many forums postings and so called solutions it still doesn't work. I created a JavaFX app in NetBeans and let it generate the _browser.jnlp for the applet.  I have a friend's website set up through goda

  • Using database templates

    Is it possible to use a database template created on a solaris system as part of a build on a LINUX system?

  • Error in BAPI_HU_CREATE

    Hi, When I execute BAPI_HU_CREATE, I get following error : "00517848450E does not have packaging material type and is therefore not a pack.mat." my code is below :        call function 'BBP_INB_DELIVERY_CREATE'           exporting             is_inb_