Created
March 7, 2015 19:57
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String getDeptName(int deptId) | |
{ | |
PreparedStatement stat = null; | |
ResultSet rs = null; | |
try | |
{ | |
String sql = "select dept_name from departments where dept_id=" + deptId; | |
stat = getAm().getDBTransaction().createPreparedStatement(sql, 1); | |
rs = stat.executeQuery(); | |
if (rs.next()) | |
{ | |
return rs.getString(1); | |
} | |
} | |
catch (Exception e) | |
{ | |
e.printStackTrace(); | |
} | |
finally | |
{ | |
if (rs != null) | |
try | |
{ | |
rs.close(); | |
} | |
catch (Exception e) | |
{ | |
} | |
if (stat != null) | |
try | |
{ | |
stat.close(); | |
} | |
catch (Exception e) | |
{ | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment