ここで使用できるpdfに基づいてDropwizard RESTfullアプリケーションを開発しています(http://it-ebooks.directory/book-1783289538.html)。私はこの問題を調査しようとしましたが、同じ問題を抱えている人はいませんでした。私は@Bindやインタフェースを使い慣れていないので、ここで私に同行してください。DropWizard APIに@Bindを使用するとSQL構文エラーが発生する
いずれにしても、自分のコンピュータにMYSQLサーバを設定して、SQLデータベースのstudentsテーブルの値をブラウザで照会するには、localhost:8080/students/[A数]。これを実現するためには、ドキュメントでは、次のコードを使用したデータベースアクセスオブジェクトのインタフェースを使用するように言う:
public interface StudentsDAO {
@Mapper(StudentMapper.class)
@SqlQuery("select * from students where studentId = :studentId")
Student getStudentById(@Bind("studentId") int studentId);
}
これは、次のコードで私のstudentResourceクラスによって使用されている:私は確認している
@Path("/students")
@Produces(MediaType.APPLICATION_JSON)
public class StudentResource {
private final StudentsDAO studentsDao;
public StudentResource(DBI jdbi) {
studentsDao = jdbi.onDemand(StudentsDAO.class);
}
@GET
@Path("/{studentId}")
public Response getStudent(@PathParam("studentId") int studentId) {
// retrieve information about the contact with the provided id
Student student = studentsDao.getStudentById(studentId);
return Response.ok(student).build();
}
...
私のMYSQLのサーバーでは、 "select * student from studentId = 123"が適切な生徒を返しますが、localhost:8080/students/123を実行すると、次のエラーが表示されます:
" SQLの構文は、マニュアルを確認corr 1" 行目の近くに「OPTIONのSQL_SELECT_LIMIT = DEFAULT」を使用する権利構文についてはMySQLサーバのバージョンにesponds
エラーをトリガラインがある:それはstudentResourceクラスでだ
Student student = studentsDao.getStudentById(studentId);
ので、私エラーが私のDAOインターフェイスの何かに関連していると仮定してください...
ありがとうございました!
ビンゴ!私はMysqlサイトから最新のJDBCコネクタドライバをダウンロードしましたが、うまくいきました.DropWizardに付属しているものは古くなっているようです... – VivaLebowski