当前位置: 技术问答>java相关
结果为空怎么板?看看我的程序
来源: 互联网 发布时间:2015-01-26
本文导语: try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con= DriverManager.getConnection("jdbc:odbc:erp","erpsys","erpsys"); Statement sta=con.createStatement(); ResultSet rs=sta.executeQuery(Sql); rs.next(); if (rs.wasNull()) { Real_psw="Unknow Use...
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con= DriverManager.getConnection("jdbc:odbc:erp","erpsys","erpsys");
Statement sta=con.createStatement();
ResultSet rs=sta.executeQuery(Sql);
rs.next();
if (rs.wasNull())
{
Real_psw="Unknow User";
}
else
{
Real_psw=rs.getString("passwd");
}
rs.close();
con.close();
if (psw.equals(Real_psw))
{
user.Set_id(id);
out.println("Login Success");
}
else
{
response.sendRedirect("Login.html");
}
}
catch(Exception e)
{
out.println(e.getMessage());
}
这段程序有问题吗?为什么结果为空是抱[Microsoft][ODBC 驱动程序 管理器] 非法的游标状态 错误?
望指教
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con= DriverManager.getConnection("jdbc:odbc:erp","erpsys","erpsys");
Statement sta=con.createStatement();
ResultSet rs=sta.executeQuery(Sql);
rs.next();
if (rs.wasNull())
{
Real_psw="Unknow User";
}
else
{
Real_psw=rs.getString("passwd");
}
rs.close();
con.close();
if (psw.equals(Real_psw))
{
user.Set_id(id);
out.println("Login Success");
}
else
{
response.sendRedirect("Login.html");
}
}
catch(Exception e)
{
out.println(e.getMessage());
}
这段程序有问题吗?为什么结果为空是抱[Microsoft][ODBC 驱动程序 管理器] 非法的游标状态 错误?
望指教
|
改成这样试试!
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con= DriverManager.getConnection("jdbc:odbc:erp","erpsys","erpsys");
Statement sta=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs = null;
rs = sta.executeQuery(Sql);
if(rs!=null && rs.next())
{
Real_psw=rs.getString("passwd");
}
else
{
Real_psw="Unknow User";
}
rs.close();
con.close();
if (psw.equals(Real_psw))
{
user.Set_id(id);
out.println("Login Success");
}
else
{
response.sendRedirect("Login.html");
}
}
catch(Exception e)
{
out.println(e.getMessage());
}
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con= DriverManager.getConnection("jdbc:odbc:erp","erpsys","erpsys");
Statement sta=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs = null;
rs = sta.executeQuery(Sql);
if(rs!=null && rs.next())
{
Real_psw=rs.getString("passwd");
}
else
{
Real_psw="Unknow User";
}
rs.close();
con.close();
if (psw.equals(Real_psw))
{
user.Set_id(id);
out.println("Login Success");
}
else
{
response.sendRedirect("Login.html");
}
}
catch(Exception e)
{
out.println(e.getMessage());
}