JSP는 새로운 세계입니다.하지만 웹 응용 프로그램에서 약간의 변경을해야합니다. 필요한 모든 것을하는 법을 알았지 만 데이터베이스에서 데이터를 가져 오는 데 문제가 있습니다.문자열이나 버퍼 길이가 잘못되었습니다
내가 here에서 예를 사용하고 있는데 내가 데이터를 표시하려면 다음 코드를 얻을 수 있습니다 : 나는 변수에 resultset.getString(1)
를 할당 할 때
while(resultset.next()){
out.println(resultset.getString(1));
}
를, 내가 얻을 :
자바 .sql.SQLException : [Microsoft] [ODBC 드라이버 관리자] 잘못된 문자열 또는 버퍼 길이
다음은 내가 사용하는 코드 :
<%
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);
%>
누군가 내가 뭘 잘못하고 있다고 말할 수 있습니까?
가치와'ctt_email'의 유형은 무엇입니까 같은 찾을 수 있습니다? –
Scriptlet을 사용하지 마십시오. 특히 Scritplets에서는 JDBC를 사용하지 마십시오. –