XMLLec 1
XMLLec 1
Author with
</AUTHOR> <!- I am comment ->
Attr id
<xs:schema>
<Students> <xs:complexType name = “StudnetType”>
<Student id=“p1”> <xs:attribute name=“id” type=“xs:string” />
<xs:element name=“Name” type=“xs:string />
<Name>Allan</Name>
<xs:element name=“Age” type=“xs:integer” />
<Age>62</Age> <xs:element name=“Email” type=“xs:string” />
<Email>[email protected] </xs:complexType>
<xs:element name=“Student” type=“StudentType” />
</Email> </xs:schema>
</Student>
</Students>
SELECT
EXTRACT(p.patientRecord,
'/Patient/@id').getStringVal()
FROM prTable p;
USE XPATH
Oracle JDBC
JDBC an API used for database connectivity
Creates Portable Applications
Basic Steps to develop JDBC Application
Import JDBC classes (java.sql.*).
Load JDBC drivers
Connect and Interact with database
Disconnect from database
Oracle JDBC
DriverManager provides basic services to
manage set of JDBC drivers
Connection object sends queries to database
server after a connection is set up
JDBC provides following three classes for
sending SQL statements to server
Statement SQL statements without parameters
PreparedStatement SQL statements to be executed multiple times with different parameters
CallableStatement Used for stored procedures
Oracle JDBC
SQL query can be executed using any of the
objects.
(Statement,PreparedStatement,CallableStatement)
Syntax (Statement Object )
Public abstract ResultSet executeQuery(String sql) throws
SQLException
Syntax (PreparedStatement,CallableStatement Object )
Public abstract ResultSet executeQuery() throws SQLException
Method executes SQL statement that returns
ResultSet object (ResultSet maintains cursor
pointing to its current row of data. )
Oracle JDBC (Example)
Import java.sql.*;
Import java.io;
Class simple{
public static void main(String[] args) throws Exception{
Connection conn=null;
try{
String conStr = "jdbc:oracle:thin:@oracle.cs.purdue.edu:1521:orb";
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection(conStr,”username”,”passwd");
Statement cursor = conn.createStatement(); // Connection Est.
ResultSet rset = stmt.executeQuery(“Select* from table_name”);
while(orset.next()){
System.out.println(“Printing column name ”+orest.getStringVal(1));
}
}Catch(ClassNotFoundException e){}
cursor.close();
conn.close();
}
}
References
[1] Database Management Systems by Ramakrishnan and Gehrke
Thank You