반응형

<%@page import="java.net.URLDecoder"%>

<%@page import="java.net.URLEncoder"%>




URLEncoder.encode(returnUrlcontent);

URLDecoder.decode(returnUrlcontent);

반응형
반응형


Nick Jonas - Home




반응형

'etc..' 카테고리의 다른 글

We have too many requests from your ip in the past 24h.  (0) 2019.10.13
N26 고객센터  (0) 2018.07.05
2017년 티스토리 결산  (0) 2018.01.07
카카오톡 pc다운로드 url주소  (0) 2017.12.04
IMB 라이센스 계약약관  (0) 2017.11.15
반응형

<%

response.setHeader("Content-Disposition", "attachment; filename=" + 파일명 + ".xls"); // 파일명

response.setHeader("Content-Description", "JSP Generated Data");

response.setContentType("application/vnd.ms-excel"); 

%>

반응형
반응형

java.sql.SQLException: Operation not allowed after ResultSet closed


에러 발생~ !!


하나의 Statement에 대해 하나의 ResultSet이 유효합니다. 


아래 참고~하였습니다.

public static void main(String[] args) throws ClassNotFoundException, SQLException {

    Connection conn = null;
    Statement stmt = null;

    Class.forName("com.mysql.jdbc.Driver");

    conn = (Connection) DriverManager.getConnection(DB_URL, USER, PASS);

    stmt = (Statement) conn.createStatement();
    String sql;
    ResultSet rs = null;
    ResultSet rs2 = null;
    ResultSet rs3 = null;
    java.sql.PreparedStatement ps = null;
    int event_id = 10;
    sql = "SELECT id,text from tweet where event_id = " + event_id;
    rs = stmt.executeQuery(sql);

    String text = "";
    Long id;
    while (rs.next()) {
        id = rs.getLong("id");
        text = rs.getString("text");
        System.out.println("tweet = " + text);
        text = text.replaceAll("http[^\\s]+", "");
        text = text.replaceAll("www[^\\s]+", "");
        System.out.println("tweet after removal of links= " + text);

        StringTokenizer st = new StringTokenizer(text);
        while (st.hasMoreTokens()) {
            String stopword = st.nextToken();
            System.out.println("stopword : " + stopword);

            sql = "SELECT * from stopwords WHERE word =" + '"'+stopword+'"';

            Statement stmt2 = conn.createStatement();
            rs2 = stmt2.executeQuery(sql);
            if (rs2.next()) {
                text = text.replaceAll(stopword, "");
                System.out.println("tweet after removing stopword = " + text);
            }
            sql = "SELECT * from filtertweet where tweet_id = " + id + "";

            Statement stmt3 = conn.createStatement();
            rs3 = stmt3.executeQuery(sql);
            if (!rs3.next()) {
                sql = "INSERT INTO filtertweet VALUES(?,?)";
                ps = conn.prepareStatement(sql);
                ps.setLong(1, id);
                ps.setString(2, text);
                ps.executeUpdate();
            }

        }
    }
    stmt.close();
    conn.close();
}


출처

반응형

+ Recent posts