javabean:
public class CheckUser {
Connection con = null;
PreparedStatement st = null;
ResultSet rs = null;
boolean b = true;
public boolean checkUser(String name,int p)
{
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@127.0.0.1:1521:yuanchao";
con = DriverManager.getConnection(url,"scott","tiger");
String sql = "select * from emp where empno=? and ename= ?";
st = con.prepareStatement(sql);
st.setInt(1, p);
st.setString(2, name);
System.out.println(sql);
System.out.println(st.execute());
boolean b
= st.execute();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
if(rs!=null)
{
try {
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(st!=null)
{
try {
st.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(con!=null)
{
try {
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(b==true)
{
return true;
}
else
{
return false;
}
}
}
}
问题好像出在红色的地方!只要赋值,返回的结果就是赋的直的结果
[[it] 本帖最后由 yc12 于 2008-9-4 16:36 编辑 [/it]]