Using database to serialize an object

I am confused as to the simplest way to serialize an object (actually a simple JavaBean) to a database through jdbc. What classes do I extend and what methods do I overwrite? There are no transient data involved.

If you expect to serialize a complex java object directly to a Relational database, it would not be possible. There are no data types which can directly hold 'objects'.
If you want to serialize a java object, and want to store it as text in a database, it would be possible. For this you can serialize the object first to a file may be, and then copy the contents of file to the database text filed.
although doing this, in my opinion, makes no sense.
Usually when you are serializing object data to a relational database you first map the data to equivalant Relational data ... A table or few colums of a table may represent your object.

Similar Messages

  • Is the best practice to use database views or view objects?

    Hi everyone,
    If the option is available, is it preferable consolidate as much data as possible into a database view instead of doing this through view view objects? It seems the answer would be yes, but I would like to hear the pros and cons related to performance, etc.
    While I do not mind a detailed discussion, practical "rule-of-thumb" advice is what I am after; I am a newbie that needs general guidelines - not theories.
    James

    Performance is the main driver behind the question because I am wondering if it is faster to send a single large record set across a network or several small ones and "assemble" them at the client level.
    Probably is better to send one large record, but you will need to take in account time required to create this one large record in db(maybe oracle object types, or arrays of oracle object types).
    Check this for some VO performance advices: Advanced View Object Techniques  (especially property: "In Batches Of" which defines number of roundtrips between app server and db)
    As far as creating an updatable database view, I know there are minor tricks that are required to make that happen from a strictly SQL standpoint. But, I am curious the best way to go in JDeveloper.
    Some solutions:
    Using Updatable Views with ADF | Real World ADF
    Andrejus Baranovskis's Blog: How to Update Data from DB View using ADF BC DoDML Method
    Dario

  • Serialization big object(100k--2M) into MYSQL database

    Hi all !
    I have a big object need to be persisted into MYSQL database in my application.
    I use two method to meet this request
    1 ---- the object implement interface Serializable, but there is serializationVersionID is not same Exception
    sometimes.
    2 ---- Use XMLEncoder to save my object, the XMLEncoder generate the object XML text about 200k -- 3 M
    , but another problem occur :
    when I call flush method of XMLEncoder, my application will full ocuppy CPU time, and memory usage will increase to 90M, sometimes will ocurr "Not enough memory" Error.
    Why?
    can some one help me?
    Thanks in advanced

    1. You are modifying the signature of one or more of your classes that alters the (system generated) serializationVersionUID and then recompiling. You can declare this for yourself to get control to some extent. See the serialization spec for details.
    2. Your object graph is very large, which might be a problem using native or xml formats. Again, the specification details ways in which you can control the serialized form of your objects.
    On the information you've provided there's not much more that can be said.

  • How to serialize a object to DataBase?

    A feasible way is that serialize the object to a file and then store this file to database. But I want to achieve it directly. How could I do?

         * Convert a serializable object to a byte array.
         * @param serializable Object to convert.
         * @return Byte array or null if failed.
         * @throws IOException on error.
        static public byte[] toByteArray(Serializable serializable) throws IOException {
            byte[] result = null;
            if (serializable != null) {
                ObjectOutputStream oos = null;
                try {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    oos = new ObjectOutputStream(baos);
                    oos.writeObject(serializable);
                    result = baos.toByteArray();
                } finally {
                    if (oos != null) {
                        oos.flush();
                        oos.close();
            }//else: input unavailbel
            return result;
        }//toByteArray()
    byte[] ba = toByteArray(mySerializableObject);
    ByteArrayInputStream bais = new ByteArrayInputStream(ba);
    preparedStatement.setBinaryStream("BINDATA", bais, ba.length)

  • How to use ADO(Microsoft ActiveX Data Objective 2.8 Library) to execute the store procedure of database in SQL server

    how to use ADO(Microsoft ActiveX Data Objective 2.8 Library) to execute the store procedure of database in SQL server?
    Does any body can tell me about this?
    thanks
    [email protected]

    Hi 
    Did you succeed to execute the procedure?
    How ?
    Thanks
    Shimon Zerbib

  • When using "Database diff" selecting other schemas only for compare own objects are shown too!

    Hi!
    For comparing lot of objects I use a priviliged account z, which can read Schema a and b.
    In the compare dialog I set different from the Defaults following Options:
    - step 1
    - option "Maintain"
    - step 3
    - button "More"
    - select schema a
    - button "Lookup"
    - mark all objects and shuttle to the right
    - repeat for schema b
    After the diff report is finished, schema object of account z are listed too, despite I have not selected this.
    Best regards
    Torsten

    Ah, you're using user Z to select objects from A & B?
    On step 2, do you have anything selected that you have not picked an object type for using the 'shuttle' in Step 3?
    For example, if you picked, 'procedures' and then in the wizard, didn't pick ANY procedures in A or B, it will by default use ALL of the procedures in Z for the compare.

  • Add rows to a Table object without using database .

    Hi everyone ,
    I'm using visual web javaServer faces framework in Netbeans IDE 6.5.I want to use a Table and bind data to it row by row ,without using database.I dont know how i must do it. i searched and find nothing exept dataprovider that as i undrestood, it use just database to bind data to a table.
    i have a string in a loop that i want to devide it to several substrings and these substrings will be each field of each row and at the end of the loop,the number of rows are equal to reapiting the loop.
    I'll appreciate any help in this matter
    Best Regard,
    Fatemeh

    My Dataout variable contains a long string of personal information. Information such as Name, Family name, Father’s name, Date of birth, National code, Nationality.
    I want to make a personal information table with above mentioned information, whereas Name, Family name, Father’s name, Date of birth, National code, Nationality will be my column values. The number of its row depends on the times that the loop is repeated.
    I can make a JTable by defining an array[6] as above, but this table doesn’t appear in Visual Web javaServer faces framework. I want to be able to do what JTable does in the Table component in visual designer. Can anybody help me?
    Thanks in advance

  • How to Execute a Remote Procedure in Portal using Database Link

    Hi,
    I followed the instructions to create a Portal form for a remote procedure. But I am encountering the following error. Can someone advise what may be the cause?
    Failed to execute - Missing string(create_package_body) language(us) domain (wwv) sub_domain (wwv_builder) (WWV-04300)
    ORA-04020: deadlock detected while trying to lock object PUBLIC.PORTLET_SCHEMA (WWV-11230)
    Failed to parse as PORTAL - (WWV-08300)
    PURPOSE
    How to execute a remote procedure in Portal using Database Link.
    DESCRIPTION
    This procedure assumes that you have two databases, one of which is remote, and Portal is configured in the other.
    Remote Database A:
    ==================
    1) Create a procedure as follows: Create or Replace PROCEDURE SCOTT.ADD_TWO_VALUES ( v_one IN NUMBER, v_two IN NUMBER, v_result OUT NUMBER) as begin v_result :=v_one+v_two; end; 2) Grant execute privileges to PUBLIC on the procedure.
    Database B (where Portal is configured): ========================================
    1) Create a public database link and choose to connect as a specific user (say SYSTEM). By default, in an Oracle 8i database, the "global_names" parameter in initSID.ora (or init.ora) file is set to "true". This Global Naming parameter enforces that a dblink has the same name as the database it connects to. Therefore, if the remote global database (A) name is "ora8.acme.com" then the database link should also be named as "ora8.acme.com".
    2) Create a synonym for the procedure in Database A. Make sure you fully qualify the procedure name in the remote database (like SCOTT.ADD_TWO_VALUES).
    3) Create a dynamic page to execute the procedure. The ORACLE tags in the dynamic page will look similar to the following: <ORACLE> DECLARE v_total NUMBER; BEGIN ADD_TWO_VALUES(:v_one,:v_two, v_total); htp.p('The total is => '); htp.p('<input type="TEXT" VALUE='||v_total||'>'); htp.para; htp.anchor('http://<machine.domain:port#>/pls/portal30/SCOTT.DYN_ADD_TWO_VALUES.show_parms', 'Re-Execute Procedure'); END; </ORACLE>
    4) Portal does not have an option to create a form based on a synonym. Therefore, if you want to create a form instead of a dynamic page, create a wrapper procedure and then create a form based on this procedure. For example: Create or Replace PROCEDURE PORTAL30.ADD_TWO_VALUES_PR ( v_one IN NUMBER, v_two IN NUMBER, v_total OUT NUMBER) as begin add_two_values(v_one, v_two, v_total); end;
    5) Grant execute privileges to PUBLIC on the procedure.

    hello...
    any input will welcomed... Thanks..

  • Using database views in ADF mobile client application

    Hi,
    I am using Jdeveloper 11.1.1.4 and WLS 10.3.4.
    I have developed a POC in ADF mobile client application both with and without synchronization. However, both work with entity objects based on tables.
    I need to use database views instead of tables. When I try to include entity object (based on views) in the view object, it shows an error saying "Only the entity objects based on tables can be selected"
    Please guide me if there is a work around for this.
    Also, please let me know if there is way to develop an ADF mobile client application skipping the use of entity objects at all and using view objects directly to specify the database query and fetch data from the database.
    Thanks in advance.
    Ansh
    Edited by: ansh on Mar 28, 2011 5:40 AM

    Hi, Ansh:
    Currently, out of box, ADF Mobile Client does not support synchronization against Database Views. This is because Mobile Server imposes some schema restrictions to ensure synchronization with multi-table views would work correctly. This schema restriction requires, for example, the view must have a primary parent table with key defined, and also all base table must be included in the data publication. These dependencies requires manual resolution and advanced planning, and is managed outside of the ADF Mobile Client/JDeveloper project.
    To continue development, you would need to create server Entity Objects directly against the base tables. You can then create the mobile ADF Business Component (EOs, VOs, etc). You can then create View Objects in your ADF Mobile Client application based on the database views, in order to retrieve the data you need exactly. In other words, instead of basing EO on the database view, create View Objects in the mobile applicaiton to mimic what you had in the View Object.
    Is there any other reason why you would need to access data via database views, instead of directly against base tables?
    Thanks,
    Joe Huang

  • Error When Using DataBase LINK in pl/sql

    I have cursor fetching some values from remote db and i m trying to store values in local table (see code below) I can run the select query alone succefully but when i use it inside plsql it fails with error.
    DECLARE
    TYPE MY_CURSOR
    IS
         REF
         CURSOR;
              THE_CURSOR MY_CURSOR;
              V_CT          NUMBER(18);
              V_PSN_ID      VARCHAR2(30);
              V_INTERNET_ID VARCHAR2(75);
         BEGIN
              V_CT                                                                           :=0;
              OPEN THE_CURSOR FOR SELECT PSN_ID, 'TEST' FROM TABLE_A@PRO1 WHERE TABLE_A.SEQ_A<=1000;
              LOOP
                   FETCH THE_CURSOR INTO V_PSN_ID, V_INTERNET_ID;
              EXIT
         WHEN THE_CURSOR%NOTFOUND;
               INSERT INTO PSN_EMAIL_SENT_TO@local
                        (PSN_ID, LAST_UPDT_DT
                        ) VALUES
                        (V_PSN_ID, SYSDATE
              V_CT:=V_CT+1;
         END LOOP;
         CLOSE THE_CURSOR;
         DBMS_OUTPUT.PUT_LINE
              TO_CHAR(V_CT)
    END;
    Error report:
    ORA-04052: error occurred when looking up remote object  TABLE_A@PRO1
    ORA-00604: error occurred at recursive SQL level 1
    ORA-04029: error ORA-1775 occurred when querying ORA_KGLR7_DEPENDENCIES
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01775: looping chain of synonyms
    ORA-02063: preceding 3 lines from PRO1
    04052. 00000 -  "error occurred when looking up remote object %s%s%s%s%s"
    *Cause:    An error has occurred when trying to look up a remote object.
    *Action:   Fix the error.  Make sure the remote database system has run
               KGLR.SQL to create necessary views used for querying/looking up
               objects stored in the database.

    You need to create the catalog views that support distributed SQL in your remote database (the database you connect to via db_link).
    To create these views, connect "/ as sysdba" and run:
    $ORACLE_HOME/rdbms/admin/catproc.sql
    which will in turn call several other scripts including: $ORACLE_HOME/rdbms/admin/catrpc.sql (which creates your missing view)
    It is best to run the whole catproc.sql script (and not just the catrpc script).
    You can run and rerun catproc.sql several times quite safely.
    Cheers

  • System Copy -- database PRR conains user object belongs to system user dbo

    Hi all,
    I am having an issue while performing the system copy for the sql server.
    Actions taken so far.
    1.Detached the database.
    2.Installed central instance in the target system .
    3.Attached the database using attach as option.
    4.Then used STM coll for the conversion.
    5.Bought sap in Up condition.
    Before detaching the database made export for java addin abap in source system
    Then I am trying to import the java add in abap using sapinst(system copy option)..In the half of the way i am getting the below message as ..
    DATABASE QAS containus user object belongs to system user dbo.
    I have performed the 551915 , 151603 but the still the same message is dispalying.
    In log files.  inserting
    TRACE [iaxxejsexp.cpp:208]
    EJS_Installer::writeTraceToLogBook()
    - Database XIA contains user objects belonging to system user dbo
    TRACE [iaxxbjsmod.cpp:301]
    CJSlibModule::showMessageBox_impl()
    <html> <head></head> <body> <b>Problems were found after checking configuration of database server b><br>- Database XIA contains user objects belonging to system user dbo<br><br>SOLUTION: Fix these problems to continue the installation. </body> </html>
    TRACE [iaxxgenimp.cpp:845]
    showDialog()
    waiting for an answer from gui
    TRACE [iaxxdlghnd.cpp:180]
    CDialogHandler::doHandleDoc()
    ACTION_OK received
    ERROR 2009-01-09 12:52:31 [iaxxinscbk.cpp:289]
    abortInstallation
    MDB-05919 Errors were found when checking connection to or configuration of database server (listed above in the log file).
    TRACE [iaxxejsbas.hpp:270]
    EJS_Base::dispatchFunctionCall()
    JS Callback has thrown std::ESAPinstException: ESAPinstException: error text undefined
    TRACE [syxxcfsmgt.cpp:430]
    CSyFileSystemMgtImpl::getFile(iastring,bool)
    lib=iamodmssql module=CIaNtMssDmo
    WARNING: THE FUNCTIONALITY YOU ARE USING IS DEPRECATED: getFile(const iastring & sFullName, bool bCaseSensitive) const. Use getFile(const PSyFSPath &) const instead.
    TRACE [syxxcfsmgt.cpp:195]
    CSyFileSystemMgtImpl::getNode(iastring,bool)
    lib=iamodmssql module=CIaNtMssDmo
    WARNING: THE FUNCTIONALITY YOU ARE USING IS DEPRECATED: getNode(const iastring & sFullName, bool bCaseSensitive) const. Use getNode(const PSyFSPath &) const instead.
    TRACE [syxxcfsmgt.cpp:921]
    CSyFileSystemMgtImpl::isExisting(iastring,bool)
    lib=iamodmssql module=CIaNtMssDmo
    WARNING: THE FUNCTIONALITY YOU ARE USING IS DEPRECATED: CSyFileSystemMgtImpl::isExisting(const iastring & , bool , ISyNode::eNodeType ) const. Use CSyFileSystemMgtImpl::isExisting(const CSyPath & , ISyNode::eNodeType ) const instead.
    WARNING 2009-01-09 12:52:31 [iaxxccntrl.cpp:477]
    CController::stepExecuted()
    The step dSetActionUnattended with step key J2EE_EngineEnterprise_Addin_OneHost|ind|ind|ind|WebAS|630|0|J2EE_EngineEnterpriseDialogs|ind|ind|ind|WebAS|630|0|J2EE_Engine|ind|ind|ind|J2EE_Engine|630|0|MssJ2eeDBSetup|ind|ind|ind|ind|ind|0|MssDatabaseInfo|ind|ind|ind|ind|ind|0|dSetActionUnattended was executed with status ERROR.
    TRACE [iaxxcsihlp.hpp:301]
    main()
    An error occurred during the installation of component SAP NetWeaver '04 SR1> SAP System Installation> Java Add-In for ABAP> MS SQL Server> Central / Distributed System> Java System Finalization. Press the log view button to get extended error information or press OK to terminate the installation. Log files are written to SAP NetWeaver '04 SR1> SAP System Installation> Java Add-In for ABAP> MS SQL Server> Central / Distributed System> Java System Finalization.
    TRACE [iaxxgenimp.cpp:845]
    showDialog()
    waiting for an answer from gui
    TRACE [iaxxdlghnd.cpp:180]
    CDialogHandler::doHandleDoc()
    ACTION_OK received
    WARNING 2009-01-09 12:52:33 [iaxxcsihlp.hpp:250]
    main()
    An error occurred during the installation.
    Regadrs
    Vijay

    Hi,
    what do you get executing this statement:
    use <SID>
    go
    select * from sys.objects where schema_id =
    (select schema_id from sys.schemas where name = 'dbo')
    go
    Sven

  • Using DBMS_LOCK to serialize the execution of packages

    Hi everybody,
    I'm having an issue with a new process that I'm working on and would love to get some feedback from the Oracle community on the best way to approach this.
    I am going to be receiving hundreds of flat files on a nightly basis that need to be processed each day. I've got a listener running on a server which will detect that a new file has been moved to a particular directory and then begin to load it into a raw tables in an 11g database. As each file finishes loading, a PL SQL package will kick off to begin creating summary tables and to do some additional transformations. However, if this package runs simulatenously for two different files then I get an ORA-00054 error because some of the transient tables that get truncated during this process conflict with one another. I'm also concerned that if this package runs too many times concurrently that it'll deadlock.
    I've been doing a lot of reading on this over the last few days, and it seems like the best approach is to use a named lock through Oracle's DBMS_LOCK package in order to throttle the execution of my packages and serialize them so that one will run only after the previous one completes. Has anybody attempted to do something like this? If so, would you mind posting some sample code so that I can implement this in the best way possible? If anyone has any other suggestions I'm open to hearing those as well. It seems like in theory the job scheduler would work for this as well, except that we've got other processes which run through that and I don't want to screw any of those up by changing the parameter to allow for concurrent jobs to run. This could end up doing more damage than good.
    Thanks in advance for your help.

    You certainly could use DBMS_LOCK to serialize access.
    At first blush, however, I would tend to question why there are transient tables that would conflict between different sessions. If you have transient tables, I would tend to expect that you would want to use global temporary tables, which eliminates the need for you to truncate them and separates data inserted by various sessions. If that's the only reason you want to serialize access, I would tend to advocate building the tables as real temporary tables and letting multiple processes run simultaneously.
    If there are other reasons that serial processing is desirable, my next thought would be to see if the listener could be made to handle the serialization. If there is just one listener process and that process waits until one file is fully processed before looking for the next file, that would seem like the cleanest way to enforce serialization.
    If you end up really wanting to use DBMS_LOCK, here is an [example of using named locks|http://www.adp-gmbh.ch/ora/plsql/sync_sessions.html]. The amount of code required is pretty minimal, particularly if they're all going to ask for an exclusive lock.
    Justin

  • Using databases and container events?

    I'm having trouble finding documents show how one should use databases and listen for container events? I'm using Berkley Java DB. I'll need all my remote object to have access to the database. How do I pass that in? Custom adapters? Also, when Tomcat shuts down I need to close the database, how would this be down? Custom adapters? So I may be answering my own question, but I'm asking cause I really don't see anything in the documentation that points this out. It really looks like I'd be using singletons and factories for this. I could register a Servlet or Servlet Context to listen for Tomcat events, but I figured it couldn't hurt to ask others using Blaze, as I'm very new to it. Thanks.

    So how would you tell Blaze to use this? Is there something you put into the config file? My thoughts on all this is to use PicoContainer to manage all services then create an adapter to inject all resources when creating remote objects. But this seems a little heavy if Blaze can do all this for me. The adapter seems like the injection point to me. Is that not what it's used for? Or is using it like that bad practice under Blaze? I've read all I can find on Blaze, so either it's missing docs, or I'm not finding them all. If I'm missing them, by all means let me know where to go. I don't want to ask questions that are already answered in documents else where.
    On Tue, May 20, 2008 at 10:51 AM, Mete Atamel <
    [email protected]> wrote:
    A new message was posted by Mete Atamel in
    General Discussion --
      Using databases and container events?
    I think it's mainly in JavaDocs but here's a sample I have where I check to make sure the HSQLDB is running as the BlazeDS starts up:
    import java.sql.Connection;
    import java.sql.SQLException;
    import flex.messaging.config.ConfigMap;
    import flex.messaging.services.AbstractBootstrapService;
    public class DatabaseCheckService extends AbstractBootstrapService
        // This is called right before server starts up.
        public void initialize(String id, ConfigMap properties)
            Connection c = null;
            try
                // Check that the database is running...
                c = ConnectionHelper.getConnection();
                // ... if yes return
                return;
            catch (SQLException e)
                System.out.println("DB is not running!");
            finally
                ConnectionHelper.close(c);
    // This is called as server is starting.
        public void start()
            // No-op
    // This is called as server is stopping.
        public void stop()
            // No-op
    View/reply at
    Using databases and container events?
    Replies by email are OK.
    Use the
    unsubscribe form to cancel your email subscription.
    "All that is necessary for the triumph of evil is that good men do nothing." - Edmund Burke

  • How to store a Non Serializable Java Object ?

    Hi..
    I have a non serializable java object which I want to store in the Oracle database and retrieve it. Can anyone help me with how to go about doing this ?
    many thanks in advance
    Ragavan

    If you share the same JVM then its possible, but I doubt that is the case. If you don't share the JVM then its
    impossible to share an object between two apps.
    But if all your attempting to do is duplicate the object in the other app then I spose it is possible, as long as
    you can reconstruct the object from information that you can interegate from the object.
    For example, if you have App A, and App B. WIthin App A is a Double d object. Then you could get the
    value of the Double by doing:
    d.doubleValue()
    write the double to a file/socket/stream, read the file/socket/stream at the other end, create a new Double
    via Double d = new Double(parsedValue);
    Now the two Apps will have a Double d object that represent the same value via a a.equals(b) == true, but
    they will not refer to the same object within memory/jvm.
    James.

  • How can I use database constraints in entity attribute validation rules

    I am interested in using database constraints to validate attributes in entity objects.
    I would like to implement a JboValidatorInterface in a way that I can use an operator like "GreaterOrEqualTo" to compare with values retrieved from the database for a column associated with an entity object attribute.
    I have used this pattern with success in other environments, where the user community decides the minimum value for a thing should change from x to y, and simply changing a database object also changes the validation methods of all applications which access it.
    I am not certain that column constraints are the appropriate vehicle, but so far that seems to be the case.
    I see that you can create a validation rule which makes comparisons against a view object attribute. I am wondering if there is a generic way to use standardized names for column constraints along with ADF hooks into properties of database columns, to avoid writing individual queries for each attribute.
    Thanks in advance!!!

    Jeffrey,
    If you already have constraints on the underlying tables, why do you need to validate them in ADF BC? You can certainly use some framework extension classes to give the user nicely formatted error messages - see ER: ADF BC - allow custom error msgs for common exceptions (e.g. DML) for more details.
    I am using this method so that anything that is enforced in the database (check constraints, foreign keys, unique constraints, etc) are not enforced in the ADF BC layer as well - after all, there's more than one way to get data into a table, and DB constraints ensure that even if data gets in through another mechanism (apart from the ADF application), it is valid. My 2 cents, of course.
    Hope this helps,
    John

Maybe you are looking for