Title: Two Ways to Connect to Oracle8
1Two Ways to Connect to Oracle8
- Note We are going to use Thin Driver
2JDBC -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
3JDBC -Thin Example
- Connection dbConnectionnull
- String driver"oracle.jdbc.driver.OracleDriver"
- try
- Class.forName(driver)
- dbConnection DriverManager.getConnection("jdbc
oraclethin_at_hostname1521SID", - userid",passwd")
- Statement statement dbConnection.createSta
tement() - ResultSet results statement.executeQuery(q
uery) -
- while(results.next())
- .
-
- catch(Exception e)..
hostname orabox.utdallas.edu SID last
4Big Picture to Save Java Object
Oracle8
Java Beans
Java Class
XML Doc.
Class
DTD Parser Middleware
JOX
JDBC
- Original 4 classes
- need be modified
- as Java Beans
- Place
- Transition
- Arch
- (Token)
- Using JOX
- Convert Beans to XML
- Using XML-DBMS (Ronald Bourret) or XDK(Oracle),
JDBC-Thin
Lib
Lib
DTD Parser(Oracle)
XML Parser(Oracle)
Ronald Bourret is a freelance programmer
5Beans 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
ltfirst-namegt 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.
6JOX - Example
Top Level Java Bean
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
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
7JOX Example (Contd)
Application to Convert
Bean.xml
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()
?xml version"1.0" encoding"ISO-8859-1"?gt ltMarkTe
stgt ltfoogt5lt/foogt ltBARgtThis is the bar
valuelt/BARgt ltS-U-B name"Joon"gt ltagegt35lt/agegt
lt/S-U-Bgt lt/MarkTestgt
8XML 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.e
du/hojch/independentStudy.html
9JDBC/XML Team Schedule
JOX Test Bean to/from XML
Joon/Hitendra
XML-DBMS/XDK Test XML to/from
Oracle8
Joon/Terence
Modify 4 classes to Beans and JOX Test
Joon
Place/ JOX Test
Hitendra
Transition/ JOX Test
Terence
Arch/ JOX Test
(Token)/ JOX Test
Joon
Place/ XML-DBMS/XDK Test
Hitendra
Transition/ XML-DBMS/XDK Test
Terence
Arch/ XML-DBMS/XDK Test
(Token)/ XML-DBMS/XDK Test
Joon/Hitendra
JOX Test Bean to Java Object
GUI/System Test
All Members
6/30
7/30
8/10