2011-12-22 12 views

答えて

1

ちょうど

boolean value = resultSet.getInt("columnName") != 0; 

を行います。

+0

ありがとうございます! – user1026305

0
public class ValueDao { 
    public static final String SELECT_VALUE = "SELECT VALUE FROM MY_TABLE"; // WHERE clause? 

    private Connection connection; 

    public ValueDao(Connection connection) { 
     this.connection = connection; 
    } 

    public boolean hasValue(String value) throws SQLException { 
     boolean hasValue = false; 

     if (value != null) { 
      Statement st = null; 
      ResultSet rs = null; 
      try { 
       st = connection.createStatement(); 
       rs = st.executeQuery(); 
       while (rs.next()) { 
        String x = rs.getString(1); 
        if (value.equals(x)) { 
         hasValue = true; 
         break; 
        } 
       } 
      } 
     } catch (SQLException e) { 
      e.printStackTrace(); 
     } finally { 
      DatabaseUtils.close(rs); // you write these cleanup methods. 
      DatabaseUtils.close(st); 
     } 

     return hasValue; 
    } 
} 
+0

詳細な回答ありがとうございます。これを行うためにあなたの一日のうちにいくつかの時間を取ることは非常にいいです。 – user1026305

0

次のような接続でJavaでクエリを実行することができます。

//Say you have a Connection conn 
//Say column for bit value is USER_BIT 
//and say 1st bit we are looking for 
PreparedStatement stmt = conn.prepareStatement("select USER_BIT & 1 from USERS where USER_ID ='123'"); 

注:コード上の図のためです。必要に応じて変更する必要があるかもしれません。

+0

ありがとうございました! – user1026305

関連する問題