Java Technologies - ISIS
Download
Report
Transcript Java Technologies - ISIS
Technologies
For possible use in the MIC-ANTS project.
Jonathan Sprinkle
Institute for Software Integrated Systems
Vanderbilt University
4 October, 1999
ANTS - Technologies
1
Overview of Technologies
Basic Java
XML
SQL
ANTS - Technologies
2
Basic Java Technologies Employed In the
Demonstration Program
Dual Applet/Application Implementation
Swing
Only Sun packages used
ANTS - Technologies
3
XML
Extensible Markup Language
Two major portions to an XML document
– Document Type Declaration (DTD)
– Document Data
Technically, three types of XML Documents:
– Valid - data conforms to the DTD
– Well-formed - 1+ elements, precisely 1 element that has no parent, and all
other tags nest within each other correctly
– Invalid - data does not conform to the DTD (parsers will toss their cookies
if they read in a document like this one)
ANTS - Technologies
4
The DTD
Has both boring and exciting portions
– Boring:
<?xml version = “1.0” ?>
<!DOCTYPE mustmatch SYSTEM “external_dtd.dtd”>
<mustmatch>
Ask not for whom the booth tolls…
</mustmatch>
ANTS - Technologies
Is this really boring? (Of course not)
Is this really useful? (Of course it is)
5
The DTD
– Exciting
<?xml version = “1.0” ?>
<!DOCTYPE SQLRESULTS [
<!ELEMENT SQLRESULTS (RESULT)*>
<!ELEMENT RESULT (film_id, manufacturer, exposures, speed, bw)*>
<!ELEMENT film_id (#PCDATA)>
<!ELEMENT manufacturer (#PCDATA)>
<!ELEMENT exposures (#PCDATA)>
<!ELEMENT speed (#PCDATA)>
<!ELEMENT bw (#PCDATA)>
]>
<SQLRESULTS>
<RESULT> ... </RESULT>
<RESULT> ... </RESULT>
...
</SQLRESULTS>
ANTS - Technologies
Is this really exciting? (you bet)
6
Types of Data
PC-DATA -- Parsed Character Data
Other Tags
– Can contain other tags (children of its tree)
– Each of these other tags is defined directly after its parent tag, and may
contain tags as its definition
– All tags (from what I can tell) eventually become “#PC-DATA”
– However, the PC-DATA need not be 7-bit ascii, it can be 8-bit, which allows
for direct binary transfer
ANTS - Technologies
7
Generic XML DTD
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE
[
<!ELEMENT
<!ELEMENT
<!ELEMENT
<!ELEMENT
<!ELEMENT
<!ELEMENT
<!ELEMENT
<!ELEMENT
<!ELEMENT
<!ELEMENT
<!ELEMENT
]>
ANTS - Technologies
DOCUMENT_EXAMPLE
DOCUMENT_EXAMPLE (A,B,C,D)*>
A (A1,B,C)>
A1 (A11,A12)*>
A11 (#PCDATA)>
A12 (#PCDATA)*>
B (#PCDATA)>
C (#PCDATA)*>
D (D1,D2,D3)*>
D1 (#PCDATA)>
D2 (#PCDATA)>
D3 (#PCDATA)>
8
SQL and Java
Basic SQL Connectivity supplied through Java API
JDBC - Java Data-Base Connectivity
– Uses a driver (which must be supplied by a vendor: in this case, Sun) which
supplies a connection to the ODBC data-source for this database
– JDBC seems to be a port for mapping Java code
– “Should” work with any ODBC-compliant database
– An interesting little bug I found
Must turn ON auto-commit to enable SQL-level transaction support.
I found this using SQL-Server 7.0, but I suspect it is a problem with the bridge,
because ODBC is way too professional to have this bug. The transactions nest
correctly, but there is no way to rollback with auto-commit off.
– Stored Procedures work, but not easy to make a general case method
ANTS - Technologies
9
SQL and XML in Java
Custom classes for SQL connectivity and CURSOR retrieval
Custom classes for XML to create a DTD from the SQL information
(ex. Column names, widths) on the fly
Native Java calls to determine row count, etc.
Custom classes to create the data of the XML document on the fly
NOTE: the DTD and XML classes are independent of SQL, and can take
any well-formed tree as the data input, as long as the DTD matches it.
ANTS - Technologies
10