我想做这个查询:
Class.forName("org.postgresql.Driver");
Connection conn= null;
conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgis","postgres","123456");
PreparedStatement ps = null;
String sql = "SELECT num FROM parcels WHERE code_initial_right =(SELECT code_document FROM documents WHERE number_document=? or date_document='"+docd+"')";
ps = conn.prepareStatement(sql);
ps.setString(1,docn);
ResultSet rs = ps.executeQuery();
但docd
可以等于null
。当我尝试这个时,我得到一个错误:
javax.servlet.ServletException: org.postgresql.util.PSQLException: ERROR: invalid input syntax for type date: ""
我能用这个做什么?