fork download
  1. // パッケージの指定
  2. package movie;
  3.  
  4. import java.util.*;
  5. import java.sql.*;
  6. import java.util.HashMap;
  7.  
  8. public class Model {
  9. private String q;
  10. private String c;
  11. private Connection conn = null;
  12. private PreparedStatement stmt = null;
  13. private ResultSet resultSet = null;
  14. private HashMap<Integer,TitleListResult>Title_hash;
  15.  
  16.  
  17. public void execute(){
  18. System.out.println("Hello");
  19.  
  20. try {
  21. conn = ConnectUtilMy.connectDatabase();
  22.  
  23.  
  24. // 住所の検索
  25. PreparedStatement pstmt = conn.prepareStatement(
  26. "SELECT title_name,years_publication,performance_income,production_cost,public_evaluation,screening_time,genre_name,original_name,cast_name,directed_name " +
  27. "FROM movie inner join original_list on movie.original_number=original_list.original_number "+
  28. "inner join genre_list on movie.genre_number=genre_list.genre_number "+
  29. "inner join directed_list on movie.directed_number=directed_list.directed_number "+
  30. "inner join cast_list on movie.cast_number=cast_list.cast_number where title_name like ? or directed_name like ?");
  31. pstmt.setString(1, q + "%");
  32. pstmt.setMaxRows(50);
  33. ResultSet rs = pstmt.executeQuery();
  34.  
  35. // 検索結果の取得
  36.  
  37. HashMap<Integer, String[]> results = new HashMap<Integer, String[]>();
  38. int i = 0;
  39. while (rs.next()) {
  40. String[] result = new String[10];
  41. result[0] = rs.getString("movie_number");
  42. result[1] = rs.getString("years_publication");
  43. result[2] = rs.getString("performance_income");
  44. result[3] = rs.getString("production_cost");
  45. result[4] = rs.getString("public_evaluation");
  46. result[5] = rs.getString("screening_time");
  47. result[6] = rs.getString("genre_number");
  48. result[7] = rs.getString("directed_number");
  49. result[8] = rs.getString("original_number");
  50. result[9] = rs.getString("cast_number");
  51. results.put(i++, result);
  52. }
  53.  
  54. // 切断
  55. rs.close();
  56. pstmt.close();
  57. conn.close();
  58. }
  59. catch (Exception ex) {
  60. ex.printStackTrace();
  61. }
  62. }
  63.  
  64. public HashMap<TitleListResult> getResults() {
  65. return results;
  66. }
  67.  
  68. public void setQ(String q) {
  69. this.q = q;
  70. }
  71.  
  72. public void setC(String c) {
  73. this.c = c;
  74. }
  75.  
  76.  
  77.  
  78. }
  79.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:8: error: class Model is public, should be declared in a file named Model.java
public class Model {
       ^
Main.java:14: error: cannot find symbol
       	private HashMap<Integer,TitleListResult>Title_hash;
       	                        ^
  symbol:   class TitleListResult
  location: class Model
Main.java:64: error: cannot find symbol
	public HashMap<TitleListResult> getResults() {
	               ^
  symbol:   class TitleListResult
  location: class Model
Main.java:64: error: wrong number of type arguments; required 2
	public HashMap<TitleListResult> getResults() {
	              ^
Main.java:21: error: cannot find symbol
                conn = ConnectUtilMy.connectDatabase();
                       ^
  symbol:   variable ConnectUtilMy
  location: class Model
Main.java:65: error: cannot find symbol
		return results;
		       ^
  symbol:   variable results
  location: class Model
6 errors
stdout
Standard output is empty