2012-03-14 3 views
0

사용자가 자동으로 기부했는지 감지하는 시스템을 만들고 있습니다. 먼저 수집 된 열이 0으로 설정된 테이블에서 레코드를 가져오고 사용자 이름은 현재 사용자 이름입니다. items 열이 있는데, 안에는 수신해야하는 내용이 들어있는 json으로 인코딩 된 배열이 있습니다. getArray 함수를 사용하여 json 배열을 문자열로 가져 오는 대신 가져와야합니다.ResultSet getArray 함수가 작동하지 않습니까?

이 오류 받고 있어요 : java.sql.SQLFeatureNotSupportedException 여기

을 내 코드 (당신은 JSON에 뭔가 문제가 발견되면 알려 주시기 그것을 테스트 할 수 없습니다 때문에의 getArray하지 않습니다 작업).

public void checkForDonation(final Player player) throws JSONException { 
    try { 
     ResultSet rs = Launcher.getDBC() 
       .getQuery(
         "SELECT * FROM `rewards` WHERE `username`= '" 
           + player.getDisplayName() 
           + "' AND `completed`='0'"); 
     if (rs.next() == true) { 
      JSONArray json = new JSONArray(); 
      JSONObject obj = new JSONObject(); 
      try { 
       obj.put("items", rs.getArray("items")); 
      } catch (org.json.JSONException e) { 
       System.err.println(e); 
       e.printStackTrace(); 
      } 
      json.put(obj); 
      System.out.println(json); 
     } 
    } catch (SQLException e) { 
     e.printStackTrace(); 
    } 
} 
+0

8 질문과 인정 0 .. – Serhiy

+0

관련없는하지만 아마 뭔가 당신이 읽어야 당신을 도울 수 some1을 받고 GL. owasp.org/index.php/SQL_Injection –

+0

어떤 DB를 사용하고 있으며 어떤 DB 드라이버를 사용하고 있습니까? java.sql.SQLFeatureNotSupportedException은 jdbc 드라이버 문제를 나타냅니다 – Alex

답변

1

getArray()는 데이터베이스에 저장된 문자열을 JSON 배열로 자동 변환하는 메서드는 아닙니다. JDBC와 JSON은 공통점이 없습니다.

읽기 its javadoc :은 https : // www가

Retrieves the value of the designated column in the current row of this ResultSet object as an Array object in the Java programming language.

Returns: an Array object representing the SQL ARRAY value in the specified column

(강조 광산)

+0

고마워요! 이것은 많은 도움이되었습니다. –

관련 문제