.NET
  Home arrow .NET arrow Providing a Complete Data Persistence Solu...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

Providing a Complete Data Persistence Solution
By: Dwight Peltzer
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 5
    2005-04-27

    Table of Contents:
  • Providing a Complete Data Persistence Solution
  • A Mapping Architectural Overview
  • Mapping Tool Types
  • Writing XML, Reading from Java

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Providing a Complete Data Persistence Solution


    (Page 1 of 4 )

    Have you ever wondered how to map your Java-based data to a relational database? This article explains how to do just that, with the help of JSQLMapper.

    Mapping your Java-based data to a relational database, such as SQL Server 2000, presents many problems difficult to resolve. For example, the SQL concept of a variable width, single-byte character array is the VARCHAR data type. The Java programming language does not contain an equivalent data type. The closest Java type is the String class.

    Most database engines internally support their own data types and convert them to a SQL data type. A perfect example is the way Oracle maps its numeric types to SQL’s NUMERIC type. Fortunately, the JDBC specification allows you to call the ResultSet.getLong() method to retrieve numbers as Java Longs. The following table displays the JDBC Specification SQL to Java datatype mappings.

    Table 1 JDBC Specification SQL to Java datatype mappings 

    SQL TypeJava TypeSQL TypeJava Type
    BITbooleanLONGVARCHARjava.lang.String
    TINYINTbyteDATEjava.sql.Date
    SMALLLINTShortTIMEjava.sql.Time
    INTEGERIntTIMESTAMPjava.sql.Timestamp
    BIGINTLongBINARYbyte
    REALFloatVARBINARYbyte
    FLOATDoubleLONGVARBINARYbyte
    DOUBLEDoubleBLOBjava.sql.Clob
    DECIMALjava.math.BigDecimalCLOBjava.sql.Array
    NUMERICjava.math.BigDecimalARRAYjava.sql.String
    CHARjava.lang.StringREFjava.sql.Ref
    VARCHARjava.lang.stringSTRUCTjava.sql.Struct

    Object-to-Relational mapping is complex for a number of reasons:

    • A mismatch exists between procedural Java and declarative SQL.
    • Objects can have one-to-many and many-to-many associations with other objects. Unfortunately, relational schema normalization doesn’t allow a column to have multiple values.
    • Relational schemas do not support inheritance.
    • Object models do not support transaction semantics.

    How do you solve these complexities? Fortunately, the JDBC APIs
    come to the rescue by assisting in mapping data from the object
    model to a relational database.

    More .NET Articles
    More By Dwight Peltzer


     

    .NET ARTICLES

    - The Transformed XML Explorer in MFC
    - List Control and Property Grid with the MFC ...
    - Font, Shell and Masked Edit Controls for MFC
    - Color, Link and Image Editor Controls for M...
    - New Controls for MFC
    - The Windows Ribbon Framework
    - Markup Language for the Ribbon Framework
    - Visually Upgrade Your MFC Project
    - New Features for the Statusbar in MFC
    - Working with the Statusbar in MFC
    - Iron Speed Design v60 Review
    - Binary and XML Serialization
    - Using CrystalReportViewer to Display Crystal...
    - Creating Summary .Net Crystal Reports
    - More on Commands, Input and the WPF





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    Stay green...Green IT