JDBC 带参数操作
/-- - 带参查询 -/ public void pare(){ String sql = "select - from studentInfo where s_id = ?" ; try { ps = getConn().prepareStatement(sql); ps.setString(1, "张三"); //传参 rs = ps.executeQuery(); //需要注意ps.executeQuery()不需要填写sql不然报错ORA-01008: 并非所有变量都已绑定 System.out.println(1); while(rs.next()){ System.out.println(rs.getString(1)+rs.getString(2)); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }
暂无