16i.txt
来自「一本关于JBuilder 应用开发的书籍,希望大家喜欢,其实我没看过的,」· 文本 代码 · 共 43 行
TXT
43 行
public void ejbLoad() throws RemoteException
{
//得到PK
_name = ((AccountPK) _context.getPrimaryKey()).name;
Connection connection = null;
PreparedStatement statement = null;
try
{
connection = getConnection();
statement = connection.prepareStatement("SELECT balance FROM Savings_Accounts WHERE name = ?");
statement.setString(1, _name);
ResultSet resultSet = statement.executeQuery();
if(!resultSet.next())
{
throw new RemoteException("Account not found: " + _name);
}
_balance = resultSet.getFloat(1);
}
catch(SQLException e)
{
throw new RemoteException("Could not load: " + _name, e);
}
finally
{
try
{
if (statement != null)
{
statement.close();
}
if (connection != null)
{
connection.close();
}
}
catch (SQLException sqe)
{
throw new RemoteException("Could not load: " + _name, sqe);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?