4. Create a SQLj project to retrieve student name and faculty name from STUDENT and FACULTY tables respectively. Use host variables declared in Java program and display retrieved rows. (Iterator problem)
What will be an ideal response?
```
import oracle.sqlj.runtime.*;
import sqlj.runtime.*;
import sqlj.runtime.ref.*;
import java.io.*;
import java.sql.*;
public class StudentFaculty {
public static void main(String [ ] args) {
#sql iterator DeptIter(String, String, String);
String l=null;
String f=null;
String n=null;
try {
Oracle.connect
("jdbc:Oracle:thin:@localhost:1521:oracle",
"nshah", "india_usa", true);
DeptIter di = null;
#sql di =
{
SELECT Last l, first f, name n
FROM student s, faculty f
WHERE s.FacultyId = f.FacultyId
};
#sql {fetch :di into :l, :f, :n};
while (!di.endFetch( )) {
System.out.println(l+"\t"+f+"\t"+n);
#sql {fetch :di into :l, :f, :n};
}
di.close( );
}
catch (SQLException e) {
System.out.println(e.getMessage( ));
}
finally {
try {
Oracle.close( );
}
catch(SQLException e) {
e.printStackTrace( );
}
}
}
}
```
You might also like to view...
A service is implemented by several servers. Explain why resources might be transferred between them. Would it be satisfactory for clients to multicast all requests to the group of servers as a way of achieving mobility transparency for clients?
What will be an ideal response?
What are the three types of countermeasures
A. Safeguards, controls, protections B. Preventative, detective, corrective C. Detective, selective, corrective D. Detective, adaptive, safeguards
What does a formal evaluation attempt to describe?
What will be an ideal response?
You can change the font attributes for all the slides in your presentation at the same time by using the font master.
Answer the following statement true (T) or false (F)