Skip to content

Instantly share code, notes, and snippets.

Created March 7, 2015 19:57
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