8
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【エラー】Parameter index out of range

Posted at

エラー

DAO,Beans,Servletを作成し、JSPを表示しようとしたところ、JSPが表示されなかった。コンソールを確認したところ下記のエラーを発見:eyes:

Parameter index out of range (4 > number of parameters, which is 3).

原因

パラメーターが4つあるのに、?が3つしかなかった:sweat_drops:

String sql = "INSERT INTO questions (question_id, answer, created_at, updated_at) values (?,?,?)";

まとめ

パラメーターと?は同じ数用意しよう:point_up:

記事が少なくて時間を浪費してしまったので備忘録。こんなミスするの私くらいだろう。

引用

java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 0)

8
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?