import java.util.Properties; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.io.*; public class helloDatabase { public static void main(String args[]) { try { /* load jdbc drivers */ Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver") .newInstance(); } catch (Exception e) { System.out.println("Exception" + e.getMessage()); } try { /* open connections to the imdb database */ /* need to update server and username/password to match current quarter info */ Connection imdbConn = DriverManager.getConnection( "jdbc:sqlserver://wsxq8lmids.database.windows.net;database=IMDB;", // database "sviyer@wsxq8lmids.database.windows.net", // user "SQLcse345"); // password PreparedStatement searchStatement = imdbConn.prepareStatement("SELECT * FROM movie WHERE name LIKE ('%Pulp Fiction%') ORDER BY id"); ResultSet movie_set = searchStatement.executeQuery(); while (movie_set.next()) { int mid = movie_set.getInt(1); System.out.println("ID: " + mid + " NAME: " + movie_set.getString(2) + " YEAR: " + movie_set.getString(3)); } imdbConn.close(); } catch (SQLException e) { System.out.println("Exception" + e.getMessage()); } } }