Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@page language ="java" contentType="text/html; charset=UTF-8"
- pageEncoding = "UTF-8" %>
- <%@page import ="java.sql.*"%>
- <%@page import ="org.json.simple.*" %>
- <%@page import ="java.util.ArrayList" %>
- <%!
- String host = "jdbc:mysql://localhost:~~~~/~~~~?useUnicode=true&characterEncoding=utf8";
- String user = "~~~~";
- String pw = "~~~~";
- %>
- <%
- String result = "";
- String sql = "";
- ResultSet rs = null;
- PreparedStatement pstmt = null;
- request.setCharacterEncoding("utf-8");
- String courseName = request.getParameter("courseName");
- int courseNo = Integer.parseInt(request.getParameter("courseNo"));
- try{
- Class.forName("com.mysql.jdbc.Driver");
- Connection conn = DriverManager.getConnection(host,user,pw);
- sql = "select Board_No from Board where Course_No= ? and Course_Name = ?";
- pstmt = conn.prepareStatement(sql);
- pstmt.setInt(1, courseNo);
- pstmt.setString(2,courseName);
- rs = pstmt.executeQuery();
- while(rs.next()){
- result = ""+rs.getInt("Board_No");
- }
- }catch(Exception e){
- result = e.getMessage();
- }
- out.println(result);
- %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement