.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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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

    - Using CrystalReportViewer to Display Crystal...
    - Creating Summary .Net Crystal Reports
    - More on Commands, Input and the WPF
    - Grouping and Aggregating When Querying LINQ ...
    - Commands, Input and the WPF
    - Keyboard and Ink Input with WPF
    - Mouse Input and the WPF
    - Input with Windows Presentation Foundation
    - Introducing LINQ with XML and Databases
    - An Introduction to LINQ
    - Querying LINQ to SQL: Basics
    - Completing a Simple Storefront with LINQ
    - Knowing Your Environment: the System.Environ...
    - Creating the Home Page for a Simple Storefro...
    - LINQ Quickly with Language Integrated Queries





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT