Providing a Complete Data Persistence Solution - Writing XML, Reading from Java (Page 4 of 4 ) JSQLMapper also provides the capability for writing XML to a database from the GUI as well as reading data from a Java program. A single class called JSQLMapper reads, writes, and deletes database data. Before you use JSQLMapper, you must import the following libraries and place them in your classpath: - sqlmapper.jar from the "lib" directory located in the install directory.
- castor-0.9.3.21.jar
- hsqldb.jar
- xercesImpl.jar
- xmlParserAPIs.jar
The following example demonstrates how to read from a file: package com.jnetdirect.sqlmapper.tutorial; import java.io.*; import java.sql.*;
//import the JSQLMapper classes import com.jnetdirect.sqlmapper.*; public class ReadTutorial { public ReadTutorial() { } public static void main(String[] args) Throws Exception { class.forName(“org.hsqldb.jdbcDriver”); Connection cn = DriverManager.getConnection (“jdbc:jsqldb:hsql://localhost”, “sa”, ““); //create an instance of the JSQLMapper class JSQLMapper sqlmapper = new JSQLMapper(new FileInputStream(“invoice. map”); sqlmapper.read(cn, new FileOutputStream (“invoices.xml”)); cn.close(); } }
Hopefully, this article will provide some stimulus for reaching out and leveraging JNetDirect’s JSQLMapper’s technology. JSQLMapper is fully J2EE compliant and is an invaluable third party business solution for bridging between Java’s J2EE specifications and .NET’s. exciting new technology. Happy computing! References - Patterns of Enterprise Application Architecture, Martin Fowler, 2003, Pearson Education
- Design Patterns, Gamma, 1995, Addison Wesley Longman
- The Unified Modeling Language User Guide, Booch, Rumbough, Jacobson, 1999, Addison Wesley
- .NET & J2EE Interoperability, Dwight Peltzer, 2004, McGraw-Hill/Osborne
- Database Programming with JDBC and Java, Reese, 2000, O’Reilly
- JNetDirect JSQLMapper API and Documentation, 2004, Doug Crane/Burke Cox
- Java 2 Enterprise Edition (J2EE) Specification 1.4
- JDBC Specification 3.0
(This article appeared, in a slightly altered form, in the May 2004 issue of Plug in). | DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
|