title: Invalid string or buffer length
body: <p>JSP is a new world for me, but I need to make a small change in a web application.  I've figured out how to do pretty much everything I need, but I'm having some problems getting data out of a database.</p>
  
  <p>I'm using an example from <a href="http://www.java2s.com/Tutorial/Java/0360__JSP/MakeDatabaseconnection.htm" rel="nofollow">here</a> and I can get the following code to display the data:</p>
  
  <pre><code>  while(resultset.next()){
          out.println(resultset.getString(1));
  
    }
  </code></pre>
  
  <p>When I try assigning <code>resultset.getString(1)</code> to a variable, I get: </p>
  
  <blockquote>
    <p>java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid string or buffer length</p>
  </blockquote>
  
  <p>Here's a sample of the code that I'm using:</p>
  
  <pre><code>        &lt;% 
        String strEmail = "";
        Connection connection = DriverManager.getConnection(
              "jdbc:odbc:dbcon", "acctName", "acctNamePass");
  
          Statement statement = connection.createStatement() ;
          ResultSet resultset = statement.executeQuery("SELECT  [ctt_email] FROM [petergriffin].[dbo].[contact] where ctt_id = 13") ; 
  
          while(resultset.next()){
              strEmail = resultset.getString(1);
  
          }
          out.println(strEmail);
  
      %&gt;      
  </code></pre>
  
  <p>Can someone tell me what I'm doing wrong?</p>