?? describe.java
字號:
package cmis.common;
import cmis.database.DBPoolManager;
import java.sql.*;
public class Describe {
public Describe() {
}
public String getNameDescription(int type, int code) {
String res = "";
DBPoolManager dbpool = new DBPoolManager();
dbpool.getConnection();
try {
String sql = "select description from code_info where type = "
+ type + " and code = " + code;
Statement selectStatement = dbpool.conn.createStatement();
ResultSet rest = selectStatement.executeQuery(sql);
if (rest.next()) {
res = rest.getString(1);
}
rest.close();
selectStatement.close();
} catch (SQLException ex) {
System.err.println("Get Description info SQLException : "
+ ex.getMessage());
} finally {
dbpool.freeConnection();
}
return res;
}
public String getTypeDescription(int type) {
String res = "";
DBPoolManager dbpool = new DBPoolManager();
dbpool.getConnection();
try {
String sql = "select name from code_info where type = " + type;
Statement selectStatement = dbpool.conn.createStatement();
ResultSet rest = selectStatement.executeQuery(sql);
if (rest.next()) {
res = rest.getString(1);
}
rest.close();
selectStatement.close();
} catch (SQLException ex) {
System.err.println("Get Type Description info SQLException : "
+ ex.getMessage());
} finally {
dbpool.freeConnection();
}
return res;
}
public String getDepartment(int dept) {
String res = "";
DBPoolManager dbpool = new DBPoolManager();
dbpool.getConnection();
try {
String sql = "select OrganName from organ where OrganID = " + dept;
Statement selectStatement = dbpool.conn.createStatement();
ResultSet rest = selectStatement.executeQuery(sql);
if (rest.next()) {
res = rest.getString(1);
}
rest.close();
selectStatement.close();
} catch (SQLException ex) {
System.err.println("Get Department info SQLException : "
+ ex.getMessage());
} finally {
dbpool.freeConnection();
}
return res;
}
public int getUserDepartment(String user) {
int dept = 0;
if (user == null) {
return 0;
}
DBPoolManager dbpool = new DBPoolManager();
dbpool.getConnection();
try {
String sql = "select a.OrganID from organ a, Staff b where "
+ "b.OrganID = a.OrganID and b.UserCode = '" + user + "'";
Statement selectStatement = dbpool.conn.createStatement();
ResultSet rest = selectStatement.executeQuery(sql);
if (rest.next()) {
dept = rest.getInt(1);
}
rest.close();
selectStatement.close();
} catch (SQLException ex) {
System.err.println("Get User Department info SQLException : "
+ ex.getMessage());
} finally {
dbpool.freeConnection();
}
return dept;
}
public String getUserName(String userId) {
String res = userId;
DBPoolManager dbpool = new DBPoolManager();
dbpool.getConnection();
try {
String sql = "select UserName from Staff where UserCode = '"
+ userId + "'";
Statement selectStatement = dbpool.conn.createStatement();
ResultSet rest = selectStatement.executeQuery(sql);
if (rest.next()) {
res = rest.getString(1);
}
rest.close();
selectStatement.close();
} catch (SQLException ex) {
System.err.println("Get User Name SQLException : "
+ ex.getMessage());
} finally {
dbpool.freeConnection();
}
return res;
}
public boolean isAdmin(String userId) {
boolean reflag = false;
DBPoolManager dbpool = new DBPoolManager();
dbpool.getConnection();
try {
String sql = "select UserName from Staff a, Staff_role b where a.UserId=b.UserId and a.UserCode = '"
+ userId + "' and b.RoleId= 0 ";
Statement selectStatement = dbpool.conn.createStatement();
ResultSet rest = selectStatement.executeQuery(sql);
if (rest.next()) {
reflag = true ;
}
rest.close();
selectStatement.close();
} catch (SQLException ex) {
System.err.println("IsAdmin SQLException : "
+ ex.getMessage());
} finally {
dbpool.freeConnection();
}
return reflag;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -