Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Two Ways to Connect to Oracle8
• Note : We are going to use Thin Driver
JDBC -Thin Driver(Oracle)
Use TCP/IP Port to access database
UserId, Password, Host name and database SID
are required to connect database
The driver is written completely in Java, requires
NO pre-installation of any software.
Support for Oracle-specific datatypes such as
ROWIDs and REFCURSORs
Supports all Oracle7 database versions and can
also access Oracle8 databases
JDBC -Thin Example
Connection dbConnection=null;
hostname : orabox.utdallas.edu
String driver="oracle.jdbc.driver.OracleDriver";
SID : last
try{
Class.forName(driver);
dbConnection =
DriverManager.getConnection("jdbc:oracle:thin:@hostname:1521:SID",
”userid",”passwd");
Statement statement = dbConnection.createStatement();
ResultSet results = statement.executeQuery(query);
while(results.next()){
………………….
}
} catch(Exception e){..}
Big Picture to Save Java Object
Java Class
Oracle8
Java Beans
XML Doc.
Class
JOX
DTD Parser &
Middleware
JDBC
•Original 4 classes
need be modified
as Java Beans
•Place
•Transition
•Arch
•(Token)
•Using JOX
•Convert Beans to XML
Lib
•Using XML-DBMS (Ronald Bourret*)
or XDK(Oracle), JDBC-Thin
Lib
•Jox115.jar
•Jaxp.jar
•Xmldbms.jar (XML-DBMS)
DTD Parser(Oracle)
•Xmlparserv2.jar
XML Parser(Oracle)
•Xmlparserv2.jar
* Ronald Bourret is a freelance programmer
Beans to XML – JOX
JOX is a set of Java libraries that make it easy to transfer data between XML documents and
Java beans.
• You must use Java Beans (get/set methods specifically). JOX uses introspection to figure
out the property names.
• XML tag names must match bean property names within reason. JOX compares XML tags
to bean properties ignoring capitalization, dashes, underscores, colons and dots. The XML
tag <first-name> will map successfully to firstName, first_name and fIrSTn_aME.
• Because XML data is in the form of a tree structure, JOX can't handle bean structures that
have circular references unless you use a DTD when writing the XML.
• JOX tries to convert XML data to the type of the bean property. There is no facility for
custom conversions.
• Without a DTD, JOX uses bean property names as XML tag names.
JOX - Example
Top Level Java Bean
public class TestBean implements java.io.Serializable
{
protected int foo;
protected String bar;
protected TestSubbean subbean; //Nested Class
public TestBean()
{
}
public int getFoo() { return foo; }
public void setFoo(int aFoo) { foo = aFoo; }
public String getBar() { return bar; }
public void setBar(String aBar) { bar = aBar; }
public TestSubbean getSub() { return subbean; }
public void setSub(TestSubbean aSub) { subbean = aSub; }
}
Nested Java Bean
public class TestSubbean
implements java.io.Serializable
{
protected String name;
protected int age;
public TestSubbean() { }
public String getName() { return name; }
public void setName(String aName)
{
name = aName;
}
public int getAge() { return age; }
public void setAge(int anAge) { age = anAge; }
JOX – Example (Cont’d)
Application to Convert
public class TestSer {
public static void main(String[] args) {
try {
TestBean b = new TestBean();
b.setFoo(5); b.setBar("This is the bar value");
TestSubbean sub = new TestSubbean();
sub.setName("Mark"); sub.setAge(35);
b.setSub(sub);
FileOutputStream fileOut =
new FileOutputStream("bean.xml");
JOXBeanOutputStream joxOut =
new JOXBeanOutputStream(fileOut);
joxOut.writeObject("MarkTest", b);
joxOut.close();
} catch (Exception exc) { exc.printStackTrace(); }
}
}
Bean.xml
?xml version="1.0" encoding="ISO-8859-1"?>
<MarkTest>
<foo>5</foo>
<BAR>This is the bar value</BAR>
<S-U-B name="Joon">
<age>35</age>
</S-U-B>
</MarkTest>
XML to/from Oracle8
To be researched …
I am going to use XML-DBMS and DTD Parser(Oracle)
Web resources to be researched…
Please visit and download related Libraries.
http://www.utdallas.edu/~hojch/independentStudy.html
JDBC/XML Team Schedule
JOX Test : Bean to/from XML
Joon/Hitendra
XML-DBMS/XDK Test :
XML to/from Oracle8
Modify 4 classes to Beans
and JOX Test
Joon/Terence
Place/ JOX Test
Joon
Transition/ JOX Test
Hitendra
Arch/ JOX Test
Terence
(Token)/ JOX Test
Place/ XML-DBMS/XDK Test
Joon
Transition/ XML-DBMS/XDK Test
Hitendra
Arch/ XML-DBMS/XDK Test
Terence
(Token)/ XML-DBMS/XDK Test
Joon/Hitendra
JOX Test : Bean to Java Object
GUI/System Test
All Members
6/30
7/30
8/10