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();
}


출처


org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: [33] in the jsp file: [  ]
tmp_field19s cannot be resolved to a variable

변수의 값의 값이 이상하여 난 오류입니다.\

Access denied(접근 거부)



https://zetawiki.com/wiki/MySQL_ERROR_1045_%EC%A0%91%EA%B7%BC_%EA%B1%B0%EB%B6%80


https://zetawiki.com/wiki/MySQL_%EC%9B%90%EA%B2%A9_%EC%A0%91%EC%86%8D



https://zetawiki.com/wiki/MySQL_%EC%9B%90%EA%B2%A9_%EC%A0%91%EC%86%8D_%ED%97%88%EC%9A%A9

#1146 Table 'mysql.server' doesn't exist가 없어서 에러발생하였습니다.


원인을 찾았으니 간단하게 생성해주면 됩니다.



CREATE TABLE `servers` (

`Server_name` CHAR(64) NOT NULL DEFAULT '',

`Host` CHAR(64) NOT NULL DEFAULT '',

`Db` CHAR(64) NOT NULL DEFAULT '',

`Username` CHAR(64) NOT NULL DEFAULT '',

`Password` CHAR(64) NOT NULL DEFAULT '',

`Port` INT(4) NOT NULL DEFAULT '0',

`Socket` CHAR(64) NOT NULL DEFAULT '',

`Wrapper` CHAR(64) NOT NULL DEFAULT '',

`Owner` CHAR(64) NOT NULL DEFAULT '',

PRIMARY KEY (`Server_name`)

)

COMMENT='MySQL Foreign Servers table'

COLLATE='utf8_general_ci'

ENGINE=MyISAM

;




기상청 rss를 통해서 날짜 파싱하기

http://www.kma.go.kr/weather/lifenindustry/sevice_rss.jsp?sido=2600000000&gugun=2647000000&x=13&y=10&dong=2644058000

rss 클릭시 아래 링크로 이동을 한후 url정보를 가져온다.

http://www.kma.go.kr/wid/queryDFSRSS.jsp?zone=2647061000

<%

// 연결+옵션설정

String url = "";

url = "http://www.kma.go.kr/wid/queryDFS.jsp?gridx=97&gridy=79";

           

 DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

 Document doc = docBuilder.parse(url);

 doc.setDocumentURI(url);

 

 NodeList nodeMomList = doc.getDocumentElement().getChildNodes();

 List xmlList = new ArrayList();

 Node row = nodeMomList.item( 3 );

 NodeList childList = row.getChildNodes();


 Node rows = childList.item( 1 );

 NodeList childLists = rows.getChildNodes();


for (int a=0; a<childLists.getLength(); a++){

Node tag_name = childLists.item(a);     // xml name tag

if(tag_name.getNodeName().equals("hour")){ //시간

xmlList.add(tag_name.getTextContent());

}

if(tag_name.getNodeName().equals("temp")){ //온도

xmlList.add(tag_name.getTextContent());

}

if(tag_name.getNodeName().equals("wfKor")){ //한글

xmlList.add(tag_name.getTextContent());

}

if(tag_name.getNodeName().equals("wfEn")){ //영어

xmlList.add(tag_name.getTextContent());

}

if(tag_name.getNodeName().equals("pop")){ //강수량

xmlList.add(tag_name.getTextContent());

}

if(tag_name.getNodeName().equals("reh")){ //습도

xmlList.add(tag_name.getTextContent());

}

}


%>



<%


for(int i=0; i < xmlList.size(); i++){

out.print(xmlList.get(i));

}

%>

해당하는 제일 위 날씨만 가져오면 되는부분이여서~ 이상하다고 생각하시는분들도 있을거라 생각합니다.

즐거운 하루 되십시오.


+ Recent posts