为什么java里面的sql中的数字型也要加引号
奇怪了,java连接oracle数据库进行检索的时候,在sqlplus里面数字型的字段可以不加引号,可我用jdbc查询的时候不加引号就检索不到数据,请问这是怎么回事呢?p...
奇怪了,java连接oracle数据库进行检索的时候,在sqlplus里面数字型的字段可以不加引号,可我用jdbc查询的时候不加引号就检索不到数据,请问这是怎么回事呢?
public List<FAQBean> getContent(int pageNum,int pageSize){
List<FAQBean> content = new ArrayList<FAQBean>();
String sql = "select * from (select t.*,rownum rn from QANDA" +
" t where t.issue ='1' and rownum <= "+pageNum*pageSize+") t1 where t1.rn >"+
(pageNum-1)*pageSize;
try{
con = new DBcon().getConnection();
st = con.createStatement();
rs = st.executeQuery(sql);
while(rs.next()){
FAQBean bean = new FAQBean();
bean.setAnswer(rs.getString("answer"));
bean.setQuestion(rs.getString("question"));
bean.setUserName(rs.getString("username"));
bean.setATime(rs.getString("atime"));
bean.setQTime(rs.getString("qtime"));
content.add(bean);
}
}catch(Exception e){
e.printStackTrace();
}finally{
try{
if(con != null)con.close();
if(st != null)st.close();
if(rs != null)rs.close();
}catch(Exception e1){
e1.printStackTrace();
}
} 展开
public List<FAQBean> getContent(int pageNum,int pageSize){
List<FAQBean> content = new ArrayList<FAQBean>();
String sql = "select * from (select t.*,rownum rn from QANDA" +
" t where t.issue ='1' and rownum <= "+pageNum*pageSize+") t1 where t1.rn >"+
(pageNum-1)*pageSize;
try{
con = new DBcon().getConnection();
st = con.createStatement();
rs = st.executeQuery(sql);
while(rs.next()){
FAQBean bean = new FAQBean();
bean.setAnswer(rs.getString("answer"));
bean.setQuestion(rs.getString("question"));
bean.setUserName(rs.getString("username"));
bean.setATime(rs.getString("atime"));
bean.setQTime(rs.getString("qtime"));
content.add(bean);
}
}catch(Exception e){
e.printStackTrace();
}finally{
try{
if(con != null)con.close();
if(st != null)st.close();
if(rs != null)rs.close();
}catch(Exception e1){
e1.printStackTrace();
}
} 展开
若以下回答无法解决问题,邀请你更新回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询