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.
I'm using an example from here and I can get the following code to display the data:
while(resultset.next()){
out.println(resultset.getString(1));
}
When I try assigning resultset.getString(1)
to a variable, I get:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid string or buffer length
Here's a sample of the code that I'm using:
<%
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);
%>
Can someone tell me what I'm doing wrong?
ctt_email
?