아래에있는 내 코드를 참조하십시오 ...jsp 형식의 정수를 데이터베이스 테이블에 삽입 하시겠습니까?
//connect
//reading params from the form
String name = request.getParameter("name");
String year_prime = request.getParameter("year");
int year = Integer.parseInt(year_prime);
//inserting the params into table Students
stmt.executeUpdate("insert into students(name,year) values('"+name+"', year)");
//close connection
가 나는 int
인 year
값을 얻고, 데이터베이스 테이블에 삽입하려합니다. 그러나 오류가 발생하고 INSERT 메서드를 경우에만 Strings
함께 작동하는 것 같습니다. 누군가이 문제로 나를 도울 수 있었습니까?
- http://www.tutorialspoint.com/jdbc/jdbc-statements.htm
- http://www.tutorialspoint.com/jdbc/statement-object-example.htm
내가 추천하지 않지만 그것은 또한 일반적인되지 않습니다 :
오류가 무엇을 얻고 있는가? 주의 할 점은 JSP에서 jdbc 연결을 만들고 사용하는 것이 일반적으로 좋지 않다는 것을 이미 알고 있기를 바랍니다. 전체 스택 추적에 오류 또는 예외를 제공 할 수 있다면 도움이 될 것입니다. 감사합니다. –