Advertisement
Guest User

Untitled

a guest
May 15th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1.  
  2. <%@page language ="java" contentType="text/html; charset=UTF-8"
  3. pageEncoding = "UTF-8" %>
  4. <%@page import ="java.sql.*"%>
  5. <%@page import ="org.json.simple.*" %>
  6. <%@page import ="java.util.ArrayList" %>
  7.  
  8. <%!
  9. String host = "jdbc:mysql://localhost:~~~~/~~~~?useUnicode=true&characterEncoding=utf8";
  10. String user = "~~~~";
  11. String pw = "~~~~";
  12. %>
  13.  
  14. <%
  15. String result = "";
  16. String sql = "";
  17. ResultSet rs = null;
  18. PreparedStatement pstmt = null;
  19. request.setCharacterEncoding("utf-8");
  20. String courseName = request.getParameter("courseName");
  21. int courseNo = Integer.parseInt(request.getParameter("courseNo"));
  22. try{
  23. Class.forName("com.mysql.jdbc.Driver");
  24. Connection conn = DriverManager.getConnection(host,user,pw);
  25. sql = "select Board_No from Board where Course_No= ? and Course_Name = ?";
  26. pstmt = conn.prepareStatement(sql);
  27. pstmt.setInt(1, courseNo);
  28. pstmt.setString(2,courseName);
  29. rs = pstmt.executeQuery();
  30. while(rs.next()){
  31. result = ""+rs.getInt("Board_No");
  32. }
  33. }catch(Exception e){
  34. result = e.getMessage();
  35. }
  36. out.println(result);
  37. %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement