我试图在SQL中从我的数据库中获取Date数据类型。 但是我得到了这个错误
java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date
ResultSet rs = stmt.executeQuery("select movie_id, movie_name, movie_dateBorrowed from movie_tbl where movie_borrower = '"+userUserID+"'");
if(rs.next()){
String moviename = rs.getString("movie_name");
Date moviedateborrowed = rs.getDate("movie_dateBorrowed");
if(movieDB!="0000-00-00"){
Date moviedateborrowed = rs.getDate("movie_dateBorrowed");
dates.add(moviedateborrowed);
}
else{
JOptionPane.showMessageDialog(null, "Unable.");
}
}
任何帮助都会成为我的一天。感谢
PS。我使用Netbeans作为我的IDE。
答案 0 :(得分:0)
Derby Date
== 0002-11-30
其他数据库可能有另一个限制。
测试就像
if(rs.next()){
String moviename = rs.getString("movie_name");
movies.add(moviename);
String DateStr = rs.getString("movie_dateBorrowed");
if (DateStr != "0000-00-00") {
Date moviedateborrowed = rs.getDate("movie_dateBorrowed");
dates.add(moviedateborrowed);
} else ...
...
}
<\ n>在else语句中,您可以使用dates.add
添加0002-11-30
(德比)