title: mysql varchar does not compute with java string
body: <p>my case:</p>
  
  <p>I try to get a value from my MySQL database. This data is defined as a VARCHAR.
  This is done in java with a prepared statement and resultset.</p>
  
  <pre><code>String add1 =rs.getString("include");
  </code></pre>
  
  <p>according to <a href="http://dev.mysql.com/doc/connector-j/en/connector-j-reference-type-conversions.html" rel="nofollow">this</a> website table 5.1 states "Can always be converted to these Java types".</p>
  
  <p>therefore a VARCHAR should be able to be converted in a java.lang.string.
  When i check the data type in java it indeed gives java.lang.string. So for so good.</p>
  
  <p>My issue is when i try to compare this obtained "String" value to a in java defined String value they don't seem to be equal.</p>
  
  <p>Let's give a simple example.
  I get the (VARCHAR) value "1" from the database and store in in String add1</p>
  
  <p>I want to check if this value is indeed "1" and therefore I use the following statement</p>
  
  <pre><code>if(add1=="1")
  {
        /* do something */   
  }    
  </code></pre>
  
  <p>Only the values are , according to java, not the same. So I was curious about why this is.</p>
  
  <p>I started searching why those two "Strings" are not equal.</p>
  
  <p>First of I checked the length of both strings. Both came out to be 1 in length as expected.</p>
  
  <p>Afterwards I checked the value of both. To see if both values where indeed the same i wanted to check their hexadecimal representance.
  Both came out with the value 0x31. Still as expected.</p>
  
  <p>But then why isn't my if statement accepted by java if both seem to represent the same string-hex-bin-you name it value.</p>
  
  <p>In short: Why is my VARCHAR "String" obtained from a MySQL databse in java not the same as a String defined in java.</p>