Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package bigdatamangementcs1;
- /**
- *
- * @author cyl1
- */
- import java.sql.*;
- public class getgenres {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- try {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- Connection conn = DriverManager.getConnection("jdbc:mysql://mysql-server-1.macs.hw.ac.uk/movielens?user=cyl1&password=abccyl1354");
- Statement st = conn.createStatement();
- String query = "SELECT * FROM genres";
- ResultSet rs = st.executeQuery(query);
- System.out.println("testing");
- while(rs.next()){
- int id = rs.getInt("id");
- String genre = rs.getString("genre");
- System.out.format("%s %s\n", id,genre);
- }
- st.close();
- conn.close();
- } catch (Exception e) {
- System.out.println("ERROR!! " +e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement