How do I store a Java ADT in a database?

Hey everyone,
I'm working on a java project and trying to implement persistent data using a java db database. One class I'm working with is a Room class and one of its fields is a list of all the people that are currently in that room. I'm new to databases so I'm not sure how to store an array like data structure in a database. Should I use a CLOB? I noticed ResultSet has a getArray() method but I can't find any documentation on an SQL ARRAY type. Is there an easy way to go about this or will I need to decide on a large fixed length field and read through that to construct my array?

genuinesmile29 wrote:
Hey everyone,
I'm working on a java project and trying to implement persistent data using a java db database. One class I'm working with is a Room class and one of its fields is a list of all the people that are currently in that room. I'm new to databases so I'm not sure how to store an array like data structure in a database. Should I use a CLOB? I noticed ResultSet has a getArray() method but I can't find any documentation on an SQL ARRAY type. Is there an easy way to go about this or will I need to decide on a large fixed length field and read through that to construct my array?No, I think you should have a parent ROOM table and a child INHABITANT table with a 1:m foreign key relationship with ROOM. Map the Room object to ROOM and the Person object to INHABITANT. Room will have a List<Person>.
%

Similar Messages

  • How to call procedure in Java from SQL Server Database

    Hello Every Body
    i Have Question about
    How to call procedure in Java from SQL Server Database
    Thanks

    Hi,
    have you tried a Google search? I just gave it a 3 second try and already found: http://stackoverflow.com/questions/6113674/how-do-i-execute-a-ms-sql-server-stored-procedure-in-java-jsp-returning-table-d
    Frank

  • How do i store and fetch image from the Database(Access)

    i am facing one problem in inserting the image into the database.the steps i followed as
    1)i have created one database(access) as "Image" and into that one table as "Image" and field as "image"
    type of the field is ole object.
    2)i have inserted one image into the image field through "database.vi"
    3)now i am trying to get the image from the database by "Fetching Example.vi"
    4)it will succesfully retrieve the image from that field .
    5)but when i close the both programs and reopen those that time i am unable to get retrieve the image.
    Attachments:
    Add_to_Database.vi ‏78 KB
    Fetch_from_database.vi ‏67 KB

    I would like to suggest different approach for saving the images in the database.
    I was working on Medical Imaging Company. The way we save the images in real-time was by writing the name and path of the images to database.
    The images themselves where saved directly to disk.
    I don�t think that access is very good in taking care of GBytes of data.
    It happens some time that the database gets damage. If you have the images separately you can create fix procedure. (We had one).
    Good Lack,
    Amit Shachaf,

  • How can I drop the java objects from a schema

    hi..good afternoon all...
    How can I drop the java objects from a database schema???
    suppose the credentials are scott/tiger@db1
    Another thing is that...I have to do this from cmd(command prompt) as there is no plsql developer or sqldeveloper installed in the machine.
    plss help...thanks in advance...

    hi...i have already tried all the options..but it is showing the error..
    ora:01435 - user does not exist
    but when i have given the command...
    select object type, object_name, status from user_objects where object_type like'%JAVA%';
    then it is showing that the java_object is present....
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL>
    SQL>
    SQL>
    SQL> set linesize 200
    SQL>
    SQL>
    SQL>
    SQL> select object_type, object_name, status from user_objects where object_type
    like '%JAVA%';
    OBJECT_TYPE OBJECT_NAME
    STATUS
    JAVA CLASS javaclass1
    VALID
    JAVA SOURCE javaclass1
    VALID
    SQL> drop java source javaclass1.java;
    drop java source javaclass1.java
    ERROR at line 1:
    ORA-01435: user does not exist
    SQL>

  • Client-Side Java Application accessing a database

    Hello Sun Forums,
    I'm developing a Java based client application which accesses a MySQL database server via JDBC.
    My question is: How can I store the password for accessing the database in a secure way on the client? I'm looking for something like the Oracle wallet. I don't know if there is a solution to this problem. Any user could do reverse engineering and extract the password out of the source code. One way hash algorithms don't work either. Any help concerning this topic is highly appreciated.
    Thanks, Yves

    YvesW wrote:
    Hello Sun Forums,
    I'm developing a Java based client application which accesses a MySQL database server via JDBC.
    My question is: How can I store the password for accessing the database in a secure way on the client? I'm looking for something like the Oracle wallet. I don't know if there is a solution to this problem. Any user could do reverse engineering and extract the password out of the source code. One way hash algorithms don't work either. Any help concerning this topic is highly appreciated.From your subsequent descriptions any 3rd party product will still not be a satisfactory solution. What you can do is to not make the DB visible by the end user and query only through request to a webserver. If you wish to adhoc type of queries, you can have a sql validation request, if your sql server supports that.
    If you cannot use a webserver interface, then throw the idea out about saving the client password, the user is just going to have to enter their password. If you are worried about entering the password and cannot use a webserver, then you don't have a project.
    Have the client call on the phone and request an extract, then send it to them on a DVD. But that can be intercepted in the mail. Even if it's encrypted, they have your data and eventually they will decrypt it.
    BTW: security is only an illusion that lets us sleep at nights, in reality, it is nothing more than a hinderance: if someone really wants to access your web connected resource, then they are going to eventually find a way to do it.

  • How to store java objects in the database

    Hi,
    I am trying to store HttpSession state across Application Servers. Basically I am trying to build a sort of application cluster server on my own. I thought the best way to do this was to periodically store the HttpSession object from an application server in a database.
    I created a table in Oracle 8i with a blob column. I use a PreparedStatement.setObject() method to store the HttpSession object in the database. My problem is, I don't know how to get the object back from the database.
    Since ResultSet.getBlob returns the Blob locator, I need to read the BinaryInputStream to get all my data back. This tells me that getBlob basically works only for things like files, and cannot be used for Java objects.
    Is there any way around this? Your input would be much appreciated.
    Regards,
    Somaiah.

    Thanks for the quick reply vramakanth.
    Do I have to use a type map if I do this? Also does such a type map exist for the HttpSession class?
    Thanks,
    Somaiah.

  • How do I store images in a jar file to be displayed on a jsp?

    Afternoon all,
    I have created a java component which accepts some parameters and returns a string. The returned string contains html tags to display a table in a webpage when rendered through a browser.
    I want to be able to add this component to any java web project to display my table. The problem is that I want to use images in my table to give the appearance of curved corners.
    How do I store images in my component and render to a webpage?
    Thanks in advance,
    Alex

    You won't be able to make the install of this library as simple as the installation of a jar file. You can't access the images directly in the jar.
    There are a few approaches you can take:
    1 - jar file + resources:
    Have the install as being a jar and a "resources" directory which you store all the images in. Thus the images become part of the web application/web site and are accessible. Probably need to allow an entry in web.xml to configure where/what this directory is called.
    2 - jar file only:
    Provide a servlet to access the images, which will load them from the jar file, using the ClassLoader.getResourceAsStream(). Requires declaration of a servlet in the web.xml file. Won't be as efficient as having the images on disk, but will keep them bundled in the jar file.
    you would generate code such as <img src="myImgServlet?img=.....">
    Cheers,
    evnafets

  • How to Fetch & Store Richtext in MySql

    Dear Friends ,
    I am Developing a System in Java - Swings , I am Using MySql as Backend .
    How can I store & retrieve Richtext in MySql.
    I am Using TextPane in Swing as the RichText Tool in Java .
    I collected Some information & which says to use BLOB / CLOB Objects to store Rich text .
    It will be Helpfull for me if you give me Ideas & Suggestions in this regard.
    I need the ways & means for storing & retrieving Richtext in MySql.
    Thanking you

    You can store RichText as BLOBs in the database. Take a look at the PreparedStatement class and the following API's:
    void setBinaryStream(int parameterIndex, InputStream x, int length)
    void setBlob(int i, Blob x)

  • How/Where to store current page details in ADF?

    Hi All,
    What is the best way to populate the managedBean while loading the page?
    In my application, I have an page fragment which display the user details from Webservice DataControl. I drag and drop the webservice data control in to the pageFragment. This fragment has mapped in the taskFlow and the taskFlow as attached in to main JSPX page as a region. I need to store this user information to any place (ManagedBean / or anyother best place to store) which I can use throughout my application, since I dont want to reexecute the webservice each time to get the same user information. Also I want to collect and store this info while I render the main page, not after any user action.
    Please advice how & where to store the information in ADF? Can I create an managedBean? If so how to trigger that class method at page load?
    Thanks
    kln

    Hi,
    in this case you configure the managed bean to be in session scope. Then, on the first page, you define a phase listener for the after restore phase (its a tag on the f:view element). This phaselistener references the managed bean using EL (important). It can do so using a method expression in JSF. For example, if the managed bean had a method populateUserInfo then yu could reference #{beanname.populateUserInfo} and execute the method expression using Java. In the managed bean, the method would access the binding layer Using the BindingContext class
    http://download.oracle.com/docs/cd/E15051_01/apirefs.1111/e10653/oracle/adf/model/BindingContext.html
    Call
    BindingContext .getCurrent().getCurrentBindingsEntry() to obtain a handle to the active instance of BindingContainer.
    BindingContainer bindings = BindingContext .getCurrent().getCurrentBindingsEntry();
    Then on the binding container, you invoke the method to query the Web Service for the user info
    //before you can call a method on the ADF binding layer, make sure the ADF binding is created for the method
    OperationBinding opws = (OperationBinding) bindings.get("name of the method exposed on WS");
    //if you need to pass parameters
    opws.getParamsMap().put("argument name",value);
    opws.execute();
    You can use similar code to access the user information from the method iterator in ADF to populate the managed bean fields. You can then access user information from the managed bean through getter and setter methods
    Frank
    Ps.: I know the description is a bit rough. I'll see if I can come up with a blog sample to a later time
    Edited by: Frank Nimphius on Jan 26, 2010 5:43 PM

  • How can I store Attributes?

    I use 'Oracle 8i' and 'XML SQL Utility for java'.
    I can store XML Elements to DB Table, but can't XML Attributes.
    The file if following..
    =================================
    <?xml version="1.0"?>
    <!DOCTYPE employee [
    <!ELEMENT employee (Name, Dept, Title)>
    <!ELEMENT Name (#PCDATA)>
    <!ATTLIST Name N_ID ID #REQUIRED>
    <!ELEMENT Dept (#PCDATA)>
    <!ELEMENT Title (#PCDATA)>
    ]>
    <employee>
    <Name N_ID>John Goodman</Name>
    <Dept>Manufacturing</Dept>
    <Title>Supervisor</Title>
    </employee>
    ======================================
    How can I store Attribute?
    Can I view source of the oracle.xml.sql.query.* ?
    null

    Hi Robert ...
    This is probably a better question for HL7. This is a tough question for
    any implementer and the different methods to do so can be matters of
    significant intellectual property for various vendors.
    regards,
    Sarah
    RobertHua wrote:
    > I want to store the CDA Documents into database,and i can get
    > information from database,
    > for example the patient node,I extract the patient information from the
    > recordTarget node.Some node have code attributes ,how can I store the
    > code information?
    > CDA Documents can have any structure by nesting the sections at any
    > depth and in any way ,how can I store the realation in the database?
    > How I can design the database?
    >
    > Thanks!!!!!!!
    >
    >

  • Read China content in JSP and store in Java variable

    Hi All ,
    I have created China language content(BinaryType) using weblogic admin console.
    And I am trying to get the content and to store in a Java Variable .
    Pls suggest me how to read other language content and to store in java variable for manipulation.
    Srinivas
    I am using following lines of code to get content
    <utility:forEachInArray array="<%=newsID%>" id="node" type="com.bea.content.Node">
    INodeManager nodeManager =     ContentManagerFactory.getNodeManager();
         java.io.InputStream is =     nodeManager.getStream(new ContentContext(), node.getId(),
    "News-Content");
    when I am using inputstream "is" to read the china content , its displaying garbage values.

    Hi Rajeev,
    My Content consist of following properties
    News-Author      String
    News-Content      Binary
    News-Id           String
    "News-Content" is Binary Type .I am creating data for this property using Content Editor.
    My data consists of 3 lines of text+image
    data will be:
    author is srinivas
    created on 11th
    content is newscontent
    << inserted image >>
    where << inserted image >> ,is jpeg file.
    I want to read this data in the JSP and store in java variable , so that i can modify 1st two lines and updated data to be displayed in browser..
    I am able to read data , if its a simple text . But it has one image also.
    How to solve this issue.
    Srinivas

  • How to set up a Java Plug-in Download page in case of netscape?

    hai all of you,
    i have a problem regarding downloading plugin.
    i am using <object > and <embed> tags to download the plugins inorder to run the applets. but it is taking long time to download the plugin form sun.com.
    so what i have done is, i downloaded the plugin.exe file and .cab file and put it in my tomcat server mainted by other party.(y application if for internet purpose only.)
    i refered to http://java.sun.com/products/plugin/1.2/docs/intranet.html. there it is mentioned that, to download the plugin.
    for I.E i can able to change the code.
    but for NetScape it's a little bit confusing.
    i have downloaded the binary file in my own directory.
    here he is asking to set up a java plugin-in download page.
    instead of this "plugin-install.html" page what page i should create and what should be the code in this page if i have to write on my own. please let me know if anybody know about it.
    following para is from sun.com
    "To deploy Java Plug-in in intranet environments with Navigator, you need to download and store the Java Plug-in binary file on one of your web servers. Then you need to set up a Java Plug-in Download page and modify the pluginspage attribute in the EMBED tag to refer to this page. The Download page should have options to download different versions of Java Plug-in, such as for Windows and Solaris. For example, if you have set up the Java Plug-in Download page at "http://javaweb.eng/plugin/" and the page is called plugin-install.html, you can specify the pluginspage as "http://javaweb.eng/plugin/plugin-install.html". "
    thanks
    by
    sambareddy

    I have successfuly done this.
    Change the converted html as per the instructions to point to another page.
    Here is an example of the new html page you need to create:
    <html>
    <head>
    <title>Java Plugin Install Page</title>
    </head>
    <body>
    <h2><center>Java Plugin Install Page</center></h2>
    <p></p>
    <h3>Windows Version Only!!!</h3>
    Click here to Download Plugin
    <p></p>
    <p>You may or may not be asked to either save or run from current location</p>
    <p>If the run from current location is available, use that option</p>
    <p>If you can only save the file, then save it to your workstation and exit the download page and exit Netscape. Then using Windows Explorer, go to where you downloaded the file and double click on the file to run it. Accept all options during the install process and once it has finished try accessing your web page again using Netscape. You should then get to the web page or application and this page will not apppear again.
    </body>
    </html>
    If you put the file j2re-1_3_1-win.exe on a web server somewhere then you will have to prefix the file with
    http://yourwebserverdirectory/
    Hope this helps.

  • How do I include a JAVA file in my website  using DreamweaverCC ?

    Hi.  I searched the forums and it seems that all questions relating to JAVA and Dreamweaver elicit zero replies.
    I hope that someone has some direction.  Thanks again.
    I have a JAVA file that I want to include or have run within one of my pages in my WebSite.
    file > new > create > and there is not an option for JAVA but there is one for PHP etc. etc.
    How do I incorporate a java script into my Web Site ?
    I thought that I could just copy the code into the file here - at least to begin with  - but JAVA  runs in the background.
    I am lost
    conceptually
    and I do not know how to go about this task
    structurally.
    Thanks again,
    Regina

    JQuery is a core JavaScript library used by millions of web sites.  It's the "do more & write less code framework."  If you're into re-inventing the wheel every time you need an advanced feature (plugin), feel free to manually code it yourself with JavaScript.  However, you'll need to test & debug your scripts in every conceivable browser and OS before you can be sure it's viable for use on a production site.
    On the other hand, you could use a plugin and be up & running in 5 minutes or less. See the code below.
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>HTML5, with Fancybox2 Viewer</title>
    <!--[if lt IE 9]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <!--LATEST JQUERY CORE LIBRARY-->
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <!--FANCYBOX plugins-->
    <link href="http://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.4/jquery.fancybox.css" rel="stylesheet" media="screen">
    <script src="http://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.4/jquery.fancybox.pack.js"></script>
    <style>
    body {
        background: silver;
        font-family:Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", Verdana, sans-serif;
    #wrapper {
        width: 1000px; margin:0 auto;
        background:#FFF;
    /**this styles image container**/
    #thumbs p {
        float: left;
        width: 180px;
        height: 12.5em;
        margin: 10px 22px 0 22px; /**space between containers**/
        padding: 10px; /**space around containers**/
        border: 1px solid silver;
        /**rounded borders**/
        -moz-border-radius: 20px;
        -webkit-border-radius: 20px;
        border-radius: 20px;
        /**this styles caption text**/
        font: italic 14px/1.5 Geneva, Arial, Helvetica, sans-serif;
        color: #666;
        text-align: center;
    /**recommend using same size images**/
    #thumbs img {
        width: 160px; /**adjust width to thumbnail**/
        height: 120px; /**adjust height to thumbnail**/
        margin-bottom: 1.5em;
        opacity: 0.75;
    #thumbs img:hover { opacity: 1.0 }
    /**float clearing**/
    #thumbs:after {
        content: ".";
        clear: left;
        font-size: 0px;
        line-height: 0;
        display: block;
        visibility: hidden;
    </style>
    </head>
    <body>
    <div id="wrapper">
    <h1><a href="http://fancyapps.com/fancybox/">Fancybox2</a> Viewer with images</h1>
    <!--insert thumbnails with links to full size images below-->
    <div id="thumbs">
    <p><a class="fancybox" data-fancybox-group="gallery" href="http://placehold.it/400x320.jpg" title="optional captions"><img src="http://placehold.it/160x120.jpg" alt="Thumbnail 1" /></a> <br />
    Caption 1 </p>
    <p><a class="fancybox" data-fancybox-group="gallery" href="http://placehold.it/400x320.jpg" title="optional captions"><img src="http://placehold.it/160x120.jpg" alt="Thumbnail 2" /></a> <br />
    Caption 2 </p>
    <p><a class="fancybox" data-fancybox-group="gallery" href="http://placehold.it/400x320.jpg" title="optional captions"><img src="http://placehold.it/160x120.jpg" alt="Thumbnail 3" /></a> <br />
    Caption 3 </p>
    <p><a class="fancybox" data-fancybox-group="gallery" href="http://placehold.it/400x320.jpg" title="optional captions"><img src="http://placehold.it/160x120.jpg" alt="Thumbnail 4" /></a> <br />
    Caption 4 </p>
    <!--end thumbs--></div>
    <!--end wrapper--></div>
    <!--FancyBox function code-->
    <script>
    $(document).ready(function() {
        $('.fancybox').fancybox();
    </script>
    </body>
    </html>
    Nancy O.

  • Fedora 13: After upgrading from FF3.6 to FF6.0.2 I no longer have a Java plugin. How do I configure the Java Plugin for FF 6 ? There is no Java Plugin at the site

    I am Fedora 13x64 bit. I just installed FF v6.0.2 from the FF download site. I backed up the existing FF 3.6 as firefox_old
    I need to have a Java plugin to access company site, how do I configure the Java Plugin ?
    At the Plugin area in FF6 there is no Java Plugin available, even after a search.
    I have Java 1.6.0 installed in the OS at:
    /usr/lib/jvm/java-1.6.0/jre/lib/amd64/libnpjp2.so
    I googled how to configure Java Plugin for FF 6 for Fedora 13 and the trick was to create a soft link from /home/<userID>/.mozilla/plugins to the above libnpjp2.so

    AVtech wrote:
    . . . If a person can't get an answer here I don't know where else to turn since Sun certainly wouldn't offer tech support for a free product . . .These forums are user forums, and only occasionally visited by Sun employees. Sun does provide Java technical support options, although (of course) at a charge.
    See:
    http://developers.sun.com/services/
    . . . I guess we'll just use JRE 5 until it's unsupported, whenever that will be. I'm still waiting for an answer on that question, too. See:
    http://java.sun.com/products/archive/eol.policy.html
    http://www.sun.com/service/eosl/
    This document (part IV and Appendix) has some debugging and troubleshooting information that may allow someone involved in the problem to resolve the cause:
    See:
    http://java.sun.com/javase/6/docs/technotes/guides/plugin/developer_guide/contents.htm
    Any steps that you can take to isolate the problem to specific Java versions, browsers, applets, web sites, operating systems (and versions), etc, would enhance the possibility of getting help.
    You can try the applets at this Sun location and see if any of them are "slow".
    See:
    http://java.sun.com/javase/6/docs/technotes/samples/demos.html

  • How can i store data in term of a tree structure

    how can i store data in term of a tree structure

    What a tree is the question. If you just want a fast access, ehats about Hashtable or dictionary classes ? The data there is structured in a tree. For a simple binary tree, you can use something like
    class Node {
    Node(Object data){
       Node left;
       Node right;
       Object data = data;
    void insert(Object data, Node parent){
      int test = data.compareTo(parent.data);
      if(test < 0 ){
        if(parent.left == null){
          parent.left = new Node(data);
        else{
          insert(data, parent.left);
      else{
        if(parent.right == null){
          parent.right = new Node(data);
        else{
          insert(data,parent.right);
    }And so build up a binary tree. The traversing methods can be found in almost any good book (pre-order, post-order, in-order), for search you have just to look at greater/smaller and descend in the tree.
    The Object data can be changed to what you want for storage, String, or primitive Numbers, Vectors ...
    Is that what you search for?

Maybe you are looking for

  • Command Order in FTPS for file adapter

    Hi, I am trying to configure file adapter using FTPS. Can anyone please explain what the commands AUTH TSL, USER, PASS, PBSZ & PROT stand for? How can i choose the correct order? Thanks Chandra

  • How to upload pdf file format in unix file directory?

    how to upload pdf file format in unix file directory?

  • Customer Aging - Column order

    Hi A user had 2 separate windows open for Customer Receivables Aging. She used a filter option on the one window which resulted in the column order in window 2 to become mixed up. Now when you run the aging report it looks like this- 0-30, Future rem

  • Weblogic proxy

    How can i forward a request coming to www.webserver.com onto www.webserver.com/portal/myportal.portal ? We are using WL Portal 8.1 and iplanet 6.0

  • CS5 export to transparent png - not working

    I have tried every think I know to get a png optimized transparently though fireworks cs5. I have read prior forum post, and watched several tutorials indicating ways to do this and when i try they do not work. I created the image in photoshop and ex