|
Create a .NET-J2EE Shared Database
Create a shared database to provide interoperability between .NET and J2EE platforms, then extend data sharing by adding a notification level between platforms.
by Simon Guest
Posted February 6, 2004
Technology Toolbox: SQL Server 2000, ADO.NET, Java, JDBC
Note: This article is excerpted from Chapter 7, "Creating a Shared Database," of Microsoft .NET and J2EE Interoperability Toolkit [Microsoft Press, 2003, ISBN: 0735619220]. It has been edited for length and format to fit the magazine. You can read a PDF of the full chapter here.
You can achieve interoperability between the Microsoft .NET Framework and Java 2 Enterprise Edition (J2EE) simply and effectively with a shared database. Database connectivity lies at the core of both .NET and J2EE, allowing you to exploit the data access drivers available for each and whip out applications that share fields, records, and tables among both platforms.
It's called business tier resource sharing. In previous projects I've worked on, certain functionality has been added to an existing application where I had to keep the same data but use technology from a different platform. For example, you might build a reporting application in which you write the reporting software for a different platform than the original application.
Here I'll show you how to create data access in the context of both .NET and J2EE and explore two connectivity options. To enable this connectivity, I'll access Microsoft SQL Server 2000 with Service Pack 3 from J2EE by using JDBC, and from .NET by using Microsoft ADO.NET.
Database connectivity APIs are core packages for both .NET and J2EE. The J2EE 1.3 specification promotes the use of JDBC to provide database access, while .NET uses ADO.NET. I'll discuss the connection and sharing of data based on Microsoft SQL Server, but you can get both JDBC and ADO.NET drivers for a variety of database providers. The net result is open data access.
I'll also tell you what you need to know about JDBC and ADO.NET in the context of using a shared database. Finally, I'll provide a data access pattern you can apply to both .NET and J2EE, and I'll cover the advantages of doing so.
JDBC is an API that enables Java apps to access fields, records, tables, and stored procedures from any database for which a JDBC driver exists. JDBC 3.0 is in its final release, but I'll use JDBC 2.0 calls here for maximum compatibility. Many vendors have produced JDBC-compatible drivers for popular databases including Microsoft SQL Server, IBM DB2, and many versions of Oracle.
ADO.NET marks the next stage in the evolution of Microsoft's data access strategy—with an emphasis on providing database access and connectivity for the .NET Framework. In addition to simple database connectivity, ADO.NET has a strong relationship with XML (to enable persistence and transport) and introduces the concept of a DataSet, allowing a disconnected view of data.
ADO.NET connects to a database through managed providers—database drivers that expose APIs with classes based on managed code, which is Microsoft Intermediate Language (MSIL) under the covers. You can get managed providers for SQL Server, Oracle 8i, and DB2. You can access other databases by using an ADO.NET managed provider to access drivers based on either OLE DB or ODBC.
Back to top
|