1 / 9

Two Ways to Connect to Oracle8

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

Download Presentation

Two Ways to Connect to Oracle8

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Two Ways to Connect to Oracle8 • Note : We are going to use Thin Driver

  2. 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

  3. JDBC -Thin Example Connection dbConnection=null; String driver="oracle.jdbc.driver.OracleDriver"; 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){..} hostname : orabox.utdallas.edu SID : last

  4. Big Picture to Save Java Object Oracle8 Java Class Java Beans 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 • Jox115.jar • Jaxp.jar • Xmldbms.jar (XML-DBMS) DTD Parser(Oracle) XML Parser(Oracle) • Xmlparserv2.jar • Xmlparserv2.jar * Ronald Bourret is a freelance programmer

  5. 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.

  6. JOX - 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; } }

  7. JOX – Example (Cont’d) 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"?> <MarkTest> <foo>5</foo> <BAR>This is the bar value</BAR> <S-U-B name="Joon"> <age>35</age> </S-U-B> </MarkTest>

  8. XML to/from Oracle8 To be researched … I am going to use XML-DBMS and DTD Parser(Oracle) Web resources to be researched… Please visitand download related Libraries. http://www.utdallas.edu/~hojch/independentStudy.html

  9. JDBC/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

More Related