im trying to get Date from my database into a JDateChooser field
TglSuratMasuk.setText(rs.getDate("tgl_surat_masuk"));
that is what i've been trying, sorry for my bad english
Since ResultSet#getDate
returns an instance of java.sql.Date
and JDateChooser#setText
expects a String
, this approach isn't going to work.
Instead, you should use the setDate
method of JDateChooser
instead.
Maybe something more like:
java.sql.Date sqlDate = rs.getDate("tgl_surat_masuk");
TglSuratMasuk.setDate(sqlDate);
'TglSuratMasuk.setDate(rs.getDate("tgl_surat_masuk"));' i've try doing this but it just give me a nullpointerexception
This means that either the ResultSet
doesn't include a column called tgl_surat_masuk
or the column type is not stored in a valid "date" type. You need to go back to your database and query and verify the type which is been stored
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.