Data Access Object for Data Warehouse?

Hi,
Does anyone know how the DAO pattern looks like when it is used for a data warehouse rather than a normal transactional database?
Normally we have something like CustomerDAO or ProductDAO in the DAO pattern, but for data warehouse applications, JOINs are used and multiple tables are queried, for example, a query may contains data from the Customer, Product and Time table, what should the DAO class be named? CustomerProductTimeDAO?? Any difference in other parts of the pattern?
Thanks in advance.
SK

In my opinion, there are no differences in the Data Access Object design pattern which have any thing to do with any characteristic of its implementation or the storage format of the data the pattern is designed to function with.
The core pupose of the DAO design pattern is to encapsulate data access code and separate it from the business logic code of the application. A DAO implementation might vary from application to application. The design pattern does not specify any implementation details. A DAO implementation can be applied to group of XML data files, an Excel-based CSV file, a relational database, or an OS file system. The design is the same for all these, it is the implementation that varies.
The core difference between an operational database and a strategic data warehouse is the purpose of why and how the data is used. It is not so much a technical difference. The relational design may vary however, there may be more tables amd ternary relationships in a data warehouse to support more fine-tuned queries; there may be less tables in a operational database to support insert/add efficiencies.
The DAO implementation for a data warehouse would be based on the model of the databases. However the tables are set up, that is how the DAO is coded.

Similar Messages

  • Database access code in objects constructor, or in data access object

    Given an object that is stored in a database, is it better to have the database access code in a constructor method, or a data access layer object? E.g. I have a Person class
    public class Person{
    int Id;
    String name;
    int age;
    }When I want to read a person's details from the database, I could use a constructor something like this:
    public Person(int id){
    Connection con = getDatabaseConnection();
    ResultSet rs = con.createStatement().executeQuery("Select name, age from person where person_id = " + id);
    rs.next();
    this.name = rs.getString(1);
    this.age=rs.getInt(2);
    }Or I could use a method in a data access object :
    public Person getPerson(int id){
    Person p = new Person();
    Connection con = getDatabaseConnection();
    ResultSet rs = con.createStatement().executeQuery("Select name, age from person where person_id = " + id);
    rs.next();
    p.setName(rs.getString(1));
    p.setAge(rs.getInt(2));
    return p;
    }It seems to me that the constructor approach has two advantages
    (1) the SQL code is kept in the relevant class (so if I want to add a field to Person, I only have to make changes to the Person class)
    (2) I don't have to have a setter method for each field
    Is one or other of these ways generally recognized as 'best practise'?

    malcolmmc wrote:
    But then, on the other hand, everytime a Person gains a new field that's two places you have to change it. if the persistence interface is written in terms of the object and uses ORM, I don't have to touch the implementation. all i have to do is update the object, the database, and the mapping - just like you and your home brew ORM.
    besides, so what? i'd fear the resource leak, bad layering, more difficult testing more.
    Actually lately I've used annotations to label setters with database field names and run a simple home brew ORM to convert rows into objects even when not using a more complex persistence manager.home brew ORM? why is that necessary when you can choose from hibernate, ibatis, jdo, jpa, etc.? that's just nuts.
    %

  • Unable to connect to the Data Access service for this management server

    Hate to raise a sleeping horse but was hoping someone might have some insight into why SCOM Report Server install is failing. I am using a domain account for SCOM 2012 R2 services in a distributive environment
    with 2 management servers and 2 SQL servers…one for Ops db and one for DW db.
     Install was failing on selecting the management server. Research led me to
    Kevin Holman's site. I followed his doc and SPN are set per your config and can telnet to MGMT1 on 5723…firewall is off on all servers. I am a domain admin and scom.mgmt account (MSOMSdkSvc) is a local admin on the MGMT servers.
    >setspn -l domain\scom.mgmt
    Registered ServicePrincipalNames for CN=scom.mgmt,OU=Service Accounts,DC= domain,DC=net:
    MSOMSdkSvc/SCOM-MGMT1
    MSOMSdkSvc/SCOM-MGMT1.domain.net
    MSOMSdkSvc/SCOM-MGMT2
    MSOMSdkSvc/SCOM-MGMT2.domain.net
    >setspn -l domain\scom-mgmt1
    Registered ServicePrincipalNames for CN=SCOM-MGMT1,OU=SCOM,OU=INTERNAL,DC=domain,DC=net:
    MSOMHSvc/SCOM-MGMT1.domain.net
    TERMSRV/SCOM-MGMT1.domain.net
    WSMAN/SCOM-MGMT1.domain.net
    RestrictedKrbHost/SCOM-MGMT1.domain.net
    HOST/SCOM-MGMT1.domain.net
    MSOMHSvc/SCOM-MGMT1
    TERMSRV/SCOM-MGMT1
    WSMAN/SCOM-MGMT1
    RestrictedKrbHost/SCOM-MGMT1
    HOST/SCOM-MGMT1
    >setspn -l domain\scom-mgmt2
    Registered ServicePrincipalNames for CN=SCOM-MGMT2,OU=SCOM,OU=INTERNAL,DC=domain,DC=net:
    MSOMHSvc/ SCOM-MGMT2.domain.net
    MSOMHSvc/ SCOM-MGMT2
    WSMAN/SCOM-MGMT2.domain.net
    WSMAN/SCOM-MGMT2
            TERMSRV/SCOM-MGMT2.domain.net
    TERMSRV/SCOM-MGMT2
    RestrictedKrbHost/SCOM-MGMT2
    HOST/CHH-SCOM-MGMT2
    RestrictedKrbHost/CHH-SCOM-MGMT2.osi-asp.net
    HOST/CHH-SCOM-MGMT2.osi-asp.net
    >setspn -l domain\scom-ssrs
    Registered ServicePrincipalNames for CN=SCOM-SSRS,OU=SCOM SQL,OU=SCOM,OU=CHH-INTERNAL,DC=domain,DC=net:
        WSMAN/SCOM-SSRS
    WSMAN/SCOM-SSRS.domain.net
    MSSQLSvc/SCOM-SSRS.domain.net
    MSSQLSvc/SCOM-SSRS.domain.net:1433
        TERMSRV/SCOM-SSRS.domain.net
    TERMSRV/SCOM-SSRS
    RestrictedKrbHost/SCOM-SSRS
      HOST/SCOM-SSRS
    RestrictedKrbHost/SCOM-SSRS.domain.net
    HOST/SCOM-SSRS.domain.net
    When I point to the MGMT server, I keep getting “Unable to connect to the Data Access service for this management server. Ensure the Data Access service is running and that the service, the management group, and setup are
    all the same version”.
    OpsMgrSetupWizard.log states…
    Info:     
    :Could not connect to Management Server: scom-mgmt1.domain.net with exception: Threw Exception.Type: System.ArgumentException, Exception Error Code: 0x80070057, Exception.Message: Version string portion was too short or
    too long.
    Info:     
    :StackTrace:   at System.Version.TryParseVersion(String version, VersionResult& result) at System.Version..ctor(String version) at Microsoft.EnterpriseManagement.OperationsManager.Setup.Common.SetupHelpers.IsManagementServerCurrentVersion(String
    managementServer) at Microsoft.EnterpriseManagement.OperationsManager.Setup.Common.SetupHelpers.CanConnectToManagementGroup(String managementServer)
    When I searched on "Exception.Message: Version string portion was too short or too long" it led me to .Net strings in the reg. i deleted all refs to older versions (3.x) but still no good.
    Bob

    Well, I’m back to trying to get SCOM Report Server up and running. This time I decided to try the command line silent install and rely on logs to debug. But it still fails.
    This is the script: SETUP /install /InstallPath:D:\Program Files\Microsoft System Center 2012 R2\Operations Manager /components:OMReporting /ManagementServer:<server>.<domain> /SRSInstance:<instance> /DataReaderUser:<domain>\<account>
    /DataReaderPassword:******** /SendODRReports:0 /UseMicrosoftUpdate:0 /AcceptEndUserLicenseAgreement:1
    When I run the script, I get a pop-up: “System CenterOperations Manager Setup has stopped working with the following:
    Problem signature:
    Problem Event Name:                       
    CLR20r3
    Problem Signature 01:                      
    setupchainerui.exe
    Problem Signature 02:                      
    7.0.5000.0
    Problem Signature 03:                      
    522a5b85
    Problem Signature 04:                      
    mscorlib
    Problem Signature 05:                      
    4.0.0.0
    Problem Signature 06:                      
    53b4fc1e
    Problem Signature 07:                      
    e4d
    Problem Signature 08:                      
    5a
    Problem Signature 09:                      
    System.FormatException
    OS Version:                                         
    6.1.7601.2.1.0.274.10
    Locale ID:                                            
    1033
    Additional Information 1:                 
    4911
    Additional Information 2:                 
    49111a576c61a461b7f2900e4224563c
    Additional Information 3:                 
    a1e6
    Additional Information 4:                 
    a1e62e9c159c1d7601a31ccff83dbf94
    App Event Log:
    - <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    - <System>
    <Provider Name=".NET Runtime" />
    <EventID Qualifiers="0">1026</EventID>
    <Level>2</Level>
    <Task>0</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2015-01-29T19:02:39.000000000Z" />
    <EventRecordID>4999</EventRecordID>
    <Channel>Application</Channel>
    <Computer>SERVER NAME</Computer>
    <Security />
    </System>
    - <EventData>
    <Data>Application: SetupChainerUI.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception.
    Exception Info: System.FormatException Stack: at Microsoft.SystemCenter.Essentials.SetupFramework.Program.Main()</Data>
    </EventData>
    </Event>
    - <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    - <System>
    <Provider Name="Application Error" />
    <EventID Qualifiers="0">1000</EventID>
    <Level>2</Level>
    <Task>100</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2015-01-29T19:02:41.000000000Z" />
    <EventRecordID>5000</EventRecordID>
    <Channel>Application</Channel>
    <Computer>SERVER NAME</Computer>
    <Security />
    </System>
    - <EventData>
    <Data>SetupChainerUI.exe</Data>
    <Data>7.1.10226.0</Data>
    <Data>522a5b85</Data>
    <Data>KERNELBASE.dll</Data>
    <Data>6.1.7601.18409</Data>
    <Data>5315a05a</Data>
    <Data>e0434352</Data>
    <Data>000000000000940d</Data>
    <Data>a64</Data>
    <Data>01d03bf626a03a7a</Data>
    <Data>C:\Users\USER NAME\AppData\Local\SCOM\Setup\SetupChainerUI.exe</Data>
    <Data>C:\Windows\system32\KERNELBASE.dll</Data>
    <Data>65be21be-a7e9-11e4-a4d7-005056966e1b</Data>
    </EventData>
    </Event>
    - <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    - <System>
    <Provider Name="Windows Error Reporting" />
    <EventID Qualifiers="0">1001</EventID>
    <Level>4</Level>
    <Task>0</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2015-01-29T19:03:27.000000000Z" />
    <EventRecordID>5001</EventRecordID>
    <Channel>Application</Channel>
    <Computer>SERVER NAME</Computer>
    <Security />
    </System>
    - <EventData>
    <Data />
    <Data>0</Data>
    <Data>CLR20r3</Data>
    <Data>Not available</Data>
    <Data>0</Data>
    <Data>setupchainerui.exe</Data>
    <Data>7.0.5000.0</Data>
    <Data>522a5b85</Data>
    <Data>mscorlib</Data>
    <Data>4.0.0.0</Data>
    <Data>53b4fc1e</Data>
    <Data>e4d</Data>
    <Data>5a</Data>
    <Data>System.FormatException</Data>
    <Data />
    <Data />
    <Data>C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_setupchainerui.e_9724aaa8eec4ffba07c27fea369e612e949d75_5b269652</Data>
    <Data />
    <Data>0</Data>
    <Data>65be21be-a7e9-11e4-a4d7-005056966e1b</Data>
    <Data>0</Data>
    </EventData>
    </Event>
    OpsMgrSetupWizard.log
    [13:48:16]:          
    Error:     :Uncaught Exception: Threw Exception.Type: System.FormatException, Exception Error Code: 0x80131537, Exception.Message: Input string was not in a correct format.
    [13:48:16]:          
    Error:     :StackTrace:  
    at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
       at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
       at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
       at Microsoft.SystemCenter.Essentials.SetupFramework.PropertyBagDictionary.GetProperty[T](String property)
       at Microsoft.EnterpriseManagement.OperationsManager.Setup.Common.SetupHelpers.ValidateBureaucraticSwitches()
       at Microsoft.EnterpriseManagement.OperationsManager.Setup.Common.RationalizeCommandLineArguments.ValidateSilentInstallCommandLineOptions()
       at Microsoft.EnterpriseManagement.OperationsManager.Setup.Common.RationalizeCommandLineArguments.Rationalize()
       at Microsoft.EnterpriseManagement.OperationsManager.Setup.Common.SetupHelpers.RationalizeGeneralInstall()
       at Microsoft.SystemCenter.Essentials.SetupFramework.Program.RationalizeInstall()
       at Microsoft.SystemCenter.Essentials.SetupFramework.Program.Main()
    Any ideas? I feel like I’m just going in circles…Bob

  • Best Practice Using Data Access Object Pattern

    I was wondering what would be the best approach with regards to implementing the Data Access Object pattern:
    Given the following database tables:
    teacher {teacher_id, teacher_name, ...}
    subject {subject_id, subject_name, ...}
    teacher_subject {teacher_id, subject_id}where teacher and subject hold details on teachers and subjects respectively and teacher_subject links teachers with the subjects that they currently teach, would I be better off:
    1) implementing three distinct DAO classes i.e. TeacherDAO, SubjectDAO, TeacherSubjectDAO, that correspond to each database table;
    2) implementing a single DAO class that controls access to all three tables, given that business operations often rely on access to all three tables e.g. getSubjectTeachers(Subject s), assignSubjectToTeacher(Subject s, Teacher t), getSubjectsTaughtBy(Teacher t)...
    Thanks
    Ian

    ...would I be better off:Depends on the system.
    If you are always going to have a teacher with subjects then all you need is one class.
    If on the other hand sometimes you are going to have subjects with teachers (given that you have a link table a many to many relationship exists) then two DAOs would exist.
    It would be unlikely for you to have a DAO for the link table unless perhaps you are anticipating a teacher having tens of thousands of subjects or one subject having tens of thousands of teachers.

  • Is it mandatory to use Business object for data transfer and work flow?

    <font size="3">
    <pre>
    In our enterprise projects we deal with some screens where we add or update some data and again
    we retrieve that data and display to user in various ways like displaying on screen as
    a report or viewing in excel etc.. Most of the times, though we identify the business objects
    based on the nouns in requirements document, really while implementing there will not be any
    business logic in the objects. Almost all the objects which we identfy as business objects
    may have methods like add, delete, update and retrieve methods. Still in these cases, is it required to
    have business objects or can we use transfer object to send the data for saving and retriving or any other
    pattern/guideline is there for dealing such cases?
    I really appreciate your comments on this topic.
    Also I apologize ahead of time if my explanation is not clear to you.
    </pre>
    </font>
    <p>
    Thanks in advance.
    <p>
    Regards,
    <p>
    Rizwan.

    In my opinion, DAO pattern would be suitable for you. Generally the DAO (Data Access Object) will have the CRUD (create, read, update, delete) methods to retrieve data from data-source (e.g. database). Based on the data it will create the DTOs (Data Transfer Objects) and pass them to the caller. It will also receive the DTOs from the caller and save it the data-source. Thus in your case you can
    - remove the CRUD methods from the Business Objects (BO) and make them pure DTOs and use them with DAOs (If you are using JDBC codes inside your application and you don't have much of validation or processing logic in your BOs).
    http://www.corej2eepatterns.com/Patterns2ndEd/DataAccessObject.htm
    OR
    - use BOs in combination in DAOs (if using the database connection from a pool and BOs are having complicated processing logic).
    http://www.corej2eepatterns.com/Patterns2ndEd/BusinessObject.htm

  • Website needs Microsoft Data Access - Active X Data Objects

    I have a number of websites for work that are seem to be built around Internet Explorer. When I try to open them on my Mac at home with Safari, I get message that I pasted below.
    I'm thinking this might be related to the fact that when I open them on a PC for the first time it shows a similar message, but Internet Explorer prompts me to download and run "Microsoft Data Access - Active X Data Objects", and then it runs fine.
    Based on this I'm assuming it's a lack of these "objects" that are causing this problem. Is there any equivalent to these components for the Mac? Anything I can try to access these websites from my Mac? I've tried using Firefox as well, which has the exact same issue.
    Right now I've got to fire up my 2006 PC laptop to use Internet Explorer every time I need access to these sites. I realize I could install windows on my Mac with bootcamp and restart in windows every time I need access, but that seems like a waste just to visit 2 websites. Any advice?
    +"Scanning Required components...+
    +The user's Internet browser requires proper configuration to access our site. Read the following instructions on how to set up the browser properly.+
    +Active Scripting Configuration:+
    +Select Tools from the Internet Explorer menu bar.+
    +Select Internet Options ...+
    +Select the Security tab.+
    +In the Web Content Zone list, select «Internet».+
    +Click Custom level....+
    +In the Settings list, scroll down to the Scripting section.+
    +Check the Enable option under the «Active scripting» item and click OK.+
    +Click Yes to confirm the change in the security settings.+
    +In the Internet Options dialog box, select the «Local intranet» and repeat steps 5 to 8.+
    +Click OK to close the dialog box."+

    Hi,
    Try this...
    From your Safari menu bar click Safari / Preferences then select the Advanced tab. Enable the develop menu.
    In the menu bar click Develop / User Agent.
    Try IE 8, 7, or 6.
    No guarantees but can't hurt to try. ActiveX requires Windows.........
    Carolyn

  • Data Access Object

    hi everyone,
    i want to basic information of Data Access Object(DAO).
    i.e. what is it?
    how to use it?
    thanks

    what it is:
    http://en.wikipedia.org/wiki/Data_Access_Object
    how to use it:
    just like any other pattern. You can check the web for examples

  • Data access Objects

    Deepak,
    Can you throw some light on the 'Data access Objects" pattern? and how it can be used with Entity beans? I am trying to apply this to the following scenario and having a hard time.
    We need users to be transparent of the data retrieval from various sources like oracle database, flat files or legacy storage. If I use the data access object pattern it is easier to use java classes in place of entity beans.
    Thanks
    Shreyas Kamat

    Shreyas,
    [For those not familiar with our Data Access Object Pattern, the
    beta version of the pattern is available on JDC (needs JDC login) at:
    http://developer.java.sun.com/developer/restricted/patterns/DataAccessObject.html]
    Data Access Objects (or DAOs) are objects that hide the database
    implementation from data clients. Data clients are any objects
    that need to retrieve data from the data source. And the data source
    could be anything that contains data, not necessarily only RDBMSs.
    For example, an external system could be a data source.
    Now using DAOs with Entity beans is applicable only in bean-managed
    persistence (BMP) scenario. In BMP, the entity beans are responsible
    to provide the data load and store implementation in the ejbLoad()
    and ejbStore() methods of the bean implementation. Without using
    the DAOs, the entity bean class will contain all the JDBC code (assuming
    that the data source is an RDBMS), SQL, etc. This makes the
    entity bean class bloated and difficult to manage when changes
    are made to the data logic. In addition, this tightly couples the
    data source implementation with the entity bean implementation.
    By using DAOs, the ejbStore() and ejbLoad() methods are much
    simpler. Also, it is easier to change from one datasource implementation
    to another by replacing the DAOs. Further flexibility is possible
    by employing the DAO factory strategy as described in the DAO pattern
    in our catalog.
    Coming back to you point about making the data access transparent
    to the clients; it is possible to achieve this by using DAO and
    DAO factory strategy. In the current version of the pattern,
    included in the book, we provide sample code to show how
    to design DAO classes and to apply DAO factory strategy.
    On your last point about using java classes instead of entity beans, this
    is not the intention of the DAO pattern. Entity beans serve a different
    purpose in the architecture as coarse-grained transactional components.
    entity beans use DAOs in BMP implementations, but are not replaced
    by DAOs. However, DAO classes are reusable. The same DAO that is
    used by an entity bean to retrieve some data in one application scenario,
    can be reused by a servlet in another application scenario
    that needs the same data, but does not use entity beans.
    So bottom line is that DAOs address the need to data access and
    manipulation and work together with entity beans in BMP implementations.
    thanks,
    -deepak

  • Data access object pattern

    Hello,
    I am trying to implement the Data Access Object pattern and I have the following bean:
    package com.netpepper.ecards;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import javax.faces.application.Action;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    * @author Julien Martin
    * Card class: represents the card sent from a member of the public (the sender)
    * to another member of the public (the recipient).
    public class Card {
         private static Log log = LogFactory.getLog(Card.class);
         private long id;
         private String from_email;
         private String to_email;
         private String image;
         private String bgcolor;
         private String font;
         private String from_name;
         private String to_name;
         private String message;
         private String title;
         private boolean received;
         private boolean sent;
         private String send_date;
         private String response;
          * Public empty no-arg constructor
         public Card() {}
          * Full-fledged constructor
         public Card(
              long id,
              String from_email,
              String to_email,
              String image,
              String bgcolor,
              String font,
              String from_name,
              String to_name,
              String message,
              String title,
              boolean received,
              boolean sent,
              String send_date) {
              setId(id);
              setFrom_email(from_email);
              setTo_email(to_email);
              setImage(image);
              setBgcolor(bgcolor);
              setFont(font);
              setFrom_name(from_name);
              setTo_name(to_name);
              setMessage(message);
              setTitle(title);
              setReceived(received);
              setSent(sent);
              setSend_date(send_date);
          * @return the background color choosed by the sender.
         public String getBgcolor() {
              return bgcolor;
          * @return the font choosed by the sender.
         public String getFont() {
              return font;
          * @return the sender's email.
         public String getFrom_email() {
              return from_email;
          * @return the sender's name.
         public String getFrom_name() {
              return from_name;
          * @return the card's id.
         public long getId() {
              return id;
          * @return the image choosed by the sender.
         public String getImage() {
              return image;
          * @return the message input by the sender.
         public String getMessage() {
              return message;
          * @return <code>true</code> if the card has been received, <code>false</code> otherwise.
         public boolean isReceived() {
              return received;
          * @return <code>true</code> if the card has been sent, <code>false</code> otherwise.
         public boolean isSent() {
              return sent;
          * @return the title choosed by the sender.
         public String getTitle() {
              return title;
          * @return the recipient's email.
         public String getTo_email() {
              return to_email;
          * @return the recipient's name.
         public String getTo_name() {
              return to_name;
          * @param the background color choosed by the sender.
         public void setBgcolor(String string) {
              bgcolor = string;
          * @param the font choosed by the sender.
         public void setFont(String string) {
              font = string;
          * @param the sender's email.
         public void setFrom_email(String string) {
              from_email = string;
          * @param the sender's name.
         public void setFrom_name(String string) {
              from_name = string;
          * @param the card's id.
         public void setId(long i) {
              id = i;
          * @param the image choosed by the sender.
         public void setImage(String string) {
              image = string;
          * @param the message input by the sender.
         public void setMessage(String string) {
              message = string;
          * @param <code>true</code> if the card has been received, <code>false</code> otherwise.
          * If the application attempts to set the received field to true,
          * then the received field of the Card object is persisted to database
          * and an email is sent to the sender to notify them that the card has been received.
         public void setReceived(boolean b) {
              if (this.received == false && b == true) {
                   Mailer m = new Mailer();
                   try {
                        m.sendAcknowlegement(
                             to_email,
                             from_email,
                             from_name,
                             to_name,
                             id);
                        Connection con = DBConnection.getConnection();
                        PreparedStatement ps =
                             con.prepareStatement(Queries.setReceivedQuery);
                        ps.setLong(1, this.id);
                        ps.executeUpdate();
                        con.close();
                        this.received = true;
                   } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
          * @param <code>true</code> if the card has been sent, <code>false</code> otherwise.
          * If the application attempts to set the send field to true,
          * then the sent field of the Card object is persisted to database.
         public void setSent(boolean b) {
              if (this.sent == false && b == true) {
                   try {
                        Connection con = DBConnection.getConnection();
                        PreparedStatement ps =
                             con.prepareStatement(Queries.setSentQuery);
                        ps.setLong(1, this.id);
                        ps.executeUpdate();
                        con.close();
                   } catch (SQLException e) {
                        log.error("ERROR: impossible to update the sent field");
                        e.printStackTrace();
          * @param the title choosed by the sender.
         public void setTitle(String string) {
              title = string;
          * @param the recipient's email.
         public void setTo_email(String string) {
              to_email = string;
          * @param the recipient's name.
         public void setTo_name(String string) {
              to_name = string;
          * @return the send date.
         public String getSend_date() {
              return send_date;
          * @param the send date.
         public void setSend_date(String string) {
              send_date = string;
          * @return <code>true</code> if email has been sent, <code>false</code> otherwise.
         public boolean sendEmail() {
              try {
                   Mailer sm = new Mailer();
                   sm.sendCard(
                        this.from_email,
                        this.to_email,
                        this.from_name,
                        this.to_name,
                        this.id);
                   return true;
              } catch (Exception e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
                   return false;
          * Retrieve the card from the database
         public static Card getCardFromId(int id) {
              Card c = new Card();
              c.id = id;
              try {
                   Connection con = DBConnection.getConnection();
                   PreparedStatement ps = con.prepareStatement(Queries.getCardFromID);
                   ps.setInt(1, id);
                   ResultSet rs = ps.executeQuery();
                   if (rs.next()) {
                        c.setBgcolor(rs.getString("db_bgcolor"));
                        c.setFont(rs.getString("db_font"));
                        c.setFrom_email(rs.getString("db_from_email"));
                        c.setTo_email(rs.getString("db_to_email"));
                        c.setFrom_name(rs.getString("db_from_name"));
                        c.setTo_name(rs.getString("db_to_name"));
                        c.setFont(rs.getString("db_font"));
                        c.setMessage((String) rs.getObject("db_message"));
                        c.setTitle(rs.getString("db_title"));
                        c.setSend_date(rs.getString("db_send_date"));
                        c.setImage(rs.getString("db_image"));
                        if (rs.getString("db_received").equals("y")) {
                             c.received = true;
                        } else if (rs.getString("db_received").equals("n")) {
                             c.setReceived(true);
                        if (rs.getString("db_sent").equals("y")) {
                             c.setSent(true);
                        } else if (rs.getString("db_sent").equals("n")) {
                             c.setSent(false);
                   System.out.println(c);
                   //con.close();
                   return c;
              } catch (SQLException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
                   return null;
         public String toString() {
              return ("Title: " + this.title + ", " + "Id: " + this.id);
          * @param string
         public void setResponse(String string) {
              response = string;
         protected String saveCard() {
              try {
                   Connection con = DBConnection.getConnection();
                   PreparedStatement ps = con.prepareStatement(Queries.saveCard);
                   ps.setLong(1, (new java.util.Date()).getTime());
                   ps.setString(2, this.from_email);
                   ps.setString(3, this.to_email);
                   ps.setString(4, this.image);
                   ps.setString(5, this.bgcolor);
                   ps.setString(6, this.font);
                   ps.setString(7, this.from_name);
                   ps.setString(8, this.to_name);
                   ps.setString(9, this.message);
                   ps.setString(10, this.title);
                   ps.setString(11, this.send_date);
                   ps.executeUpdate();
                   con.close();
                   return "saved";
              } catch (SQLException e) {
                   log.error("ERROR: impossible to save the card");
                   e.printStackTrace();
                   return "notSaved";
         public Action getSaveCard() {
              return new Action() {
                   public String invoke() {
                        return saveCard();
    }The full source code for the project can be downloaded here:
    http://cours.java.free.fr/ecards-project/
    I would like to decouple the bean from the jdbc but I don't know how to. Can anyone help please?
    I found some sampes here http://access1.sun.com/codesamples/DataAccessObject.html
    but it does not have any update jdbc.
    Julien.

    Your DAO should have methods for getting and setting beans.
    For example:
    public Card getCard(long id){...}
    public void updateCard(Card c) {...}

  • Data Access Object  relationship with other tables

    Hi,
    I have two entities which are related. One is customer other is account.
    I need to get accounts of the customer as well , when I do a search for customer.
    I am using data access objects both for customer and account.
    Now where shall do the above mentioned search.
    Do I have to write one sql in Customer Data Access Object or does the Customer DAO has to refer to Account DAO to get account details.
    Which method is the best.
    Thanking You,
    Chamal.

    I have two entities which are related. One is
    customer other is account.
    I need to get accounts of the customer as well , when
    I do a search for customer.You might want to consider what you want to do if you need to display a list of customers.
    >
    I am using data access objects both for customer and
    account.
    Now where shall do the above mentioned search.
    Do I have to write one sql in Customer Data Access
    Object or does the Customer DAO has to refer to
    Account DAO to get account details.
    Which method is the best.
    If it was me the Account DAO would have a method that takes a customer id and returns a list of Accounts.
    Customer would have a method that used that method.
    That requires two queries though. Your requirements might drive the need for a single query (which returns two result sets.) If that was the case then I would still have the extraction logic in the Account class - the customer class would pass the extracted sub result set to it and it would return an account list.

  • Data Access Objects and associations....

    Ive got a few classes which are 'value based', and represent some configuration for some dynamic part of my application.
    I was going to employ the Data Access Objects pattern (http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html) to decouple the data source (either XML or RDB in this case) from the content.
    In my case though, I have associations between the content.
    E.g, an X contains 0..n Ys' which have 0..1 Zs'.
    So, X has 'getYs()' for example.
    Is the DAO pattern meant for cases like this, or just for single data object cases (E.g, 'Customer') with simple properties?
    I cant see any disadvantages for using it in my case, but wondered if any one has any thoughts on the design?

    The aim of the DAO is to hide the implementation of the datasource to the clients (i.e the classes using it). And the reason is the client should not care how the data is stored. It also means that I can change the way I store my data without changing the client(s) code (the client calls interface methods that do not change).
    If your code satisfies the above, it is implementing DAO, and it should not and does not matter how many Y's are in your X's or Z's...
    Always make a distinction between the general aim of a Design Pattern (its essence) and the (usually simple, even simplistic) examples supplied by different authors to illustrate the pattern.

  • Data Access Objects : JDBC Driver Not Found

    Hi,
    I am having a strange problem accessing JDBC Driver ( for Informix Database, if this
    information helps )
    I am using Data Access Objects ( DAOs ) to fetch multiple records.
    The DAO is accessed from Session Bean for this case.
    The constructor of the DAO does the JNDI lookup for the TxDataSource
    and set it to a class attribute of the DAO. This DataSource is pointing
    to a connection pool
    In the getConnection() private method if DAO we use this DataSource
    to pickup a onnection from the pool and fire a sql query.
    This public method say getMultipleRecords( query conditions ) of DAO
    returns a number of macthing records to the Session Bean.
    This approach works fine in general. But sometimes I get an
    java.sql.SQLException
    SQLException ERROR MESSAGE is:
    "Error accessing jdbc driver: driverURL = jdbc:weblogic:pool:myConnPool, props= {enableTwoPhaseCommit=true,
    connectionPoolID=myConnPool}"
    Once this exception occurs every time the method is called the same exception keep
    coming.
    Once I restart the server this API starts working again.
    Could anyone give any reason why this exception might occur.
    Please send an e-mail to [email protected] while replying to this message.
    Thanks in advance
    Gunajit

    Hi Gunajit
    you need to ensure that the connections are properly closed. If you are
    closing the connections properly, increase the number of connections in the
    connection pool.
    hth
    sree
    "Gunajit" <[email protected]> wrote in message
    news:3ce082ca$[email protected]..
    >
    Hi,
    I am having a strange problem accessing JDBC Driver ( for InformixDatabase, if this
    information helps )
    I am using Data Access Objects ( DAOs ) to fetch multiple records.
    The DAO is accessed from Session Bean for this case.
    The constructor of the DAO does the JNDI lookup for the TxDataSource
    and set it to a class attribute of the DAO. This DataSource is pointing
    to a connection pool
    In the getConnection() private method if DAO we use this DataSource
    to pickup a onnection from the pool and fire a sql query.
    This public method say getMultipleRecords( query conditions ) of DAO
    returns a number of macthing records to the Session Bean.
    This approach works fine in general. But sometimes I get an
    java.sql.SQLException
    SQLException ERROR MESSAGE is:
    "Error accessing jdbc driver: driverURL = jdbc:weblogic:pool:myConnPool,props= {enableTwoPhaseCommit=true,
    connectionPoolID=myConnPool}"
    Once this exception occurs every time the method is called the sameexception keep
    coming.
    Once I restart the server this API starts working again.
    Could anyone give any reason why this exception might occur.
    Please send an e-mail to [email protected] while replying to this
    message.
    >
    Thanks in advance
    Gunajit

  • Data Access Objects (Wizard)

    Does SJSE 8 happen to have a wizard that allows you to use the database explorer and create Data Access Objects from tables? If not does anybody know of a good tool to do so. I will be working with IBM iSeries (DB2).

    I worked on a JDO runtime a long time ago during JDO's infancy, so I'm personally biased towards it . I like it because it allows you to treat your data objects as normal java objects instead of heavy-weight objects such as CMP beans. As I remember, the JDO runtime I worked on used byte code enhancer to inject code into your byte code to keep track of changes made by plain assignment statements. (Not sure if it works that way for other implementations.)
    You might want to check out the following link on SDN:
    http://java.sun.com/products/jdo/
    Also, there is FAQ on JDO vs. J2EE Persistence you should read before you make a decision:
    http://java.sun.com/j2ee/persistence/faq.html
    Good luck.

  • Managed Beans and Data Access Object

    I have a question / need help understanding how to configure backing bean and model objects so that memory and object creation/deletion is done as efficiently as possible.
    1. I have a .jsf page with a form and a commandbutton that submits the form inputs to a backing bean (enrollispbean is backing bean)
    <h:commandButton value="Enter" action="#{enrollispbean.insert}"/>
    2. The backing bean is used for form handling - the insert() method is used to read the data fields from the form and create a SQL string that will be submitted to a model object, DbInsert, that is used as a generic data access object that connects to the database and insert the SQL string:
    public class EnrollIspBean {
    private String beanvar1="";
    private String beanvar2= "";
    // DbInsert is data access object
    private DbInsert dbinsert = new DbInsert();
    public String insert (){
    String sqlstmt;
    sqlstmt = "INSERT INTO ispmain VALUES(beanvar1, beanvar2,..)"
    dbinsert.insert(sqlstmt);
    return "success"; }
    3. DbInsert is the data access object that contains a method, insert(), that accepts a sql string to insert into the database. This method contains the code to obtain a connection from the database connection pool and then execute the sql statement (note: error checking code not shown):
    public class DbInsert {
    public void insert(String sqlstmt) throws SQLException {
    Connection conn = null;
    GetDBConnection getdbconnection = new GetDBConnection();
    PreparedStatement stmt = null;
    conn = getdbconnection.getdbconn();
    stmt = conn.prepareStatement(sqlstmt);
    stmt.executeUpdate();
    stmt.close();
    conn.close();
    return;
    Where I need help understanding is how to set up the scope for the managed beans and data access object. Currently, I have the backing bean within the session scope (using the facesconfig.xml file). My main question is how to set up the scope for the Data Access Object - currently I do not have it as a managed bean within facesconfig.xml. Instead I am creating a new instance within the backing bean:
    private DbInsert dbinsert = new DbInsert();
    Is this the best way to do this? Will the DBInsert object now be tied to the session scope of the backing bean (i.e., when backing bean is deleted, the DbInsert object will be deleted from session scope as well.)
    Ideally I would like the data access object to be available as a shared object throughout the life of the application. When I was programming using a servlet approach, I would have created a servlet to load on startup. Now that I'm using java server faces, I'm confused about the scope / how to efficiently set up a data access object that I want to be available to all backing beans in the application.
    tnanks for any help understanding this.
    Tom

    I was thinking about setting the data access object as application scope so that it can be used by an backing bean to execute sql statements.
    If I do set it as application scope, however, if I do this, do I still need to declare a new instance of the object from within each bean that uses the object?
    For example do I need to declare a new instance of the data access object from within the bean? or, should I assume that there is always an instance of the bean available in the application scope, and if so, how do I reference it from within the bean?
    Bean Code:
    public class EnrollIspBean {
    // DbInsert is data access object
    private DbInsert dbinsert = new DbInsert();
    Finally, I understand performance may be an issue if I have one instance of the data access object available in the application scope - is there a way to make multiple instances available in the application scope?
    thanks

  • Issue while Installing Oracle Data Access Software for Windows

    All,
    Iam getting the following error while installing Oracle Data Access Software for windows. Iam installing in WindowsXP, with Oracle 9i release 9.2.0.7.0 DB and client in the same Box.
    It shows
    The Specified Key key was not found while trying to GetValue
    * Stop installation of all Products
    * Stop installtion of this componenent only.
    Kindly let me know why this error is showing up.
    Regards
    Ramesh

    Most probably you have hit this issue:
    "If you have more than one Oracle Home installed on the same machine (e.g. Oracle8i client and Oracle9i Release 2 client), use the Oracle Home Selector to run your applications with Oracle9i Release 2 client. "
    As documented on the Oracle Data Access Software for Windows. Release 9.2.0.4.0
    ~ Madrid.

Maybe you are looking for

  • DVI to s-video adpater for Power Mac G4?

    I'm attempting to view digitial photos on my Power Mac G4 on an HDTV with an s-video connection. I've tried Apple's "DVI to video adapter" for the Power Mac G5, but it doesn't work, even after clicking "Detect Displays". Is there a DVI to s-video ada

  • Error When Executing DTP

    Internal error: Invalid Aggregation Info No entry for InfoObject: 0CURTYPE  - contact SAP Message no. RSTRAN000. when i am loading data to DSO using Data Transfer Process i am getting this error. Transformation is also in Active Mode. I dont know why

  • Problems with apple ID

    I have been using my debit card to make purchases on iTunes,  all of sudden I was unable to make purchases on iTunes because my payment method was invalid. I then tried to use my credit card on iTunes again I was informed that my payment method was i

  • HT4236 Is there a way to sync photos from my computer onto my Ipod touch 'Camera Roll' album?

    Everytime I sync photos from my computer onto my ipod they go into two different folders, and not the camera roll. I really want to have them in the camera roll and was wondering if there was a way to do so, Thanks. Georgia.

  • Locking in forms

    i have a doubt in that in my application, users can select some sequential numbers from a table, i am using the following statement to lock a record once the user has selected a record and not to allow the other user to see this particular record and