Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package filmdatabase;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.Statement;
- import java.sql.SQLException;
- import java.util.Scanner;
- public class FilmDatabase {
- private static String user, pass, host, serviceName;
- private static Connection conn;
- private static Scanner userInput;
- public static void main(String[] args) throws SQLException {
- // TODO code application logic here
- loadOracleJdbcDriver();
- connectToServer(user, pass, host, serviceName);
- }
- public FilmDatabase() {
- }
- public static void loadOracleJdbcDriver() {
- try {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- } catch (ClassNotFoundException e) {
- System.out.println("Error -" + e.toString());
- System.out.println("Could not load the driver");
- }
- }
- public static void connectToServer(String user, String pass,
- String host, String serviceName) throws SQLException {
- try {
- Scanner sc = new Scanner(System.in);
- user = sc.next();
- pass = sc.next();
- host = sc.next();
- serviceName = "xe";
- System.out.println(user + " " + pass + " " + host);
- System.out.println("Connecting to Database...");
- // userid, password and hostname are obtained from the console
- try ( //try-with-resources
- Connection conn = DriverManager.getConnection("jdbc"
- + ":oracle:thin:"
- + user + "/" + pass + "@" + host + ":1521/"
- + serviceName)) {
- /* JDBC default is to commit each SQL statement
- as it is sent to the database.
- Setting autocommmit=false
- changes the default
- behaviour so that transactions
- have to be committed explicity.
- */
- conn.setAutoCommit(false);
- }
- } catch (SQLException e) {
- System.out.println("Error + " + e.toString());
- System.out.println("Connection Failure");
- }
- }
- public static void createFilmTable() throws SQLException {
- Statement s = conn.createStatement();
- }
- public static void populateFilmTable() {
- }
- public static void getTitleAllFilms() throws SQLException, FileNotFoundException {
- FileInputStream film = new FileInputStream("src/Film.txt");
- }
- public static void getTitleAllFilmsWithoutTitleTag() {
- }
- public static void getActorNameGodFather() {
- }
- public static void getTitleYearAllCrimeFilms() {
- }
- public static void getTitleYearAllFilmsFtMarlonBrando() {
- }
- public static void getAllFilmsOneDirector() {
- }
- public static void getTitleNameDirectorsMoreThanOneDirector() {
- }
- public static void getNameActorAndDirectorSameFilm() {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement