PreparedStatement不能用
我用jdbc连接oracle10数据库,连接都是对的,也能连接数据库。
但当我用PreparedStatement的传参方式时却不能用。
如我用
PreparedStatement pstmt = conn.prepareStatement("select count(*) from tab_AA where aa=?");
pstmt.setString(1,"aaaa");
rs = pstmt.executeQuery();
这样查不出结果
但当我这样写时
PreparedStatement pstmt = conn.prepareStatement("select count(*) from tab_AA where aa='"+aa+"'");
rs = pstmt.executeQuery();
却能查出数据。
请问各位这是什么原因啊,我错在哪里?