当前位置: 技术问答>java相关
¥¥¥到底是什么问题,一个简单的函数,应该怎么写¥¥¥
来源: 互联网 发布时间:2015-05-08
本文导语: 包含在另一文件,编译有错误,程序段如下: 这是函数部分:在 check_function_right.jsp 文件中 public boolean check_function_right(String login_id,String function_name)throws SQLException{ String lg_id = login_id; String function = func...
包含在另一文件,编译有错误,程序段如下:
这是函数部分:在 check_function_right.jsp 文件中
public boolean check_function_right(String login_id,String function_name)throws SQLException{
String lg_id = login_id;
String function = function_name;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn_right=java.sql.DriverManager.getConnection("jdbc:odbc:MIS","MIS2001","MIS250901");
Statement stmt_access_right=conn_right.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
String sql_access_right="SELECT * FROM Access_Right WHERE LgID='"+ login_id +"' AND Function='"+ function +"' ";
ResultSet rs_access_right=stmt_access_right.executeQuery(sql_access_right);
if(rs_access_right.next()){
return true;
}
else{
return false;
}
}
函数包含在以下文件中
这是函数部分:在 check_function_right.jsp 文件中
public boolean check_function_right(String login_id,String function_name)throws SQLException{
String lg_id = login_id;
String function = function_name;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn_right=java.sql.DriverManager.getConnection("jdbc:odbc:MIS","MIS2001","MIS250901");
Statement stmt_access_right=conn_right.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
String sql_access_right="SELECT * FROM Access_Right WHERE LgID='"+ login_id +"' AND Function='"+ function +"' ";
ResultSet rs_access_right=stmt_access_right.executeQuery(sql_access_right);
if(rs_access_right.next()){
return true;
}
else{
return false;
}
}
函数包含在以下文件中
|
这样就没错误了,我试了!包都引了的情况下:
public boolean check_function_right(String login_id,String function_name)throws SQLException{
String lg_id = login_id;
String function = function_name;
try{////////////////////////////////////////////////
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(Exception e)
{
System.out.println(e.getMessage());
}///////////////////////////////////////////////////////
Connection conn_right=java.sql.DriverManager.getConnection("jdbc:odbc:MIS","MIS2001","MIS250901");
Statement stmt_access_right=conn_right.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
String sql_access_right="SELECT * FROM Access_Right WHERE LgID='"+ login_id +"' AND Function='"+ function +"' ";
ResultSet rs_access_right=stmt_access_right.executeQuery(sql_access_right);
if(rs_access_right.next()){
return true;
}
else{
return false;
}
}
public boolean check_function_right(String login_id,String function_name)throws SQLException{
String lg_id = login_id;
String function = function_name;
try{////////////////////////////////////////////////
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(Exception e)
{
System.out.println(e.getMessage());
}///////////////////////////////////////////////////////
Connection conn_right=java.sql.DriverManager.getConnection("jdbc:odbc:MIS","MIS2001","MIS250901");
Statement stmt_access_right=conn_right.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
String sql_access_right="SELECT * FROM Access_Right WHERE LgID='"+ login_id +"' AND Function='"+ function +"' ";
ResultSet rs_access_right=stmt_access_right.executeQuery(sql_access_right);
if(rs_access_right.next()){
return true;
}
else{
return false;
}
}
|
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(Exception e){}
有些类的方法调用会抛出异常,调用者必须要对异常进行处理!!!
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(Exception e){}
有些类的方法调用会抛出异常,调用者必须要对异常进行处理!!!