基本上没用过,快忘记了。
public static void setDeathAge(Poet dyingBard, int age);
throws SQLException
{
Connection con = null;
CallableStatement proc = null;
try
{
con = connectionPool.getConnection();;
proc = con.prepareCall("{ call set_death_age(?, ?); }");;
proc.setString(1, dyingBard.getName(););;
proc.setInt(2, age);;
proc.execute();;
}
finally
{
try
{
proc.close();;
}
catch (SQLException e); {}
con.close();;
}
}
//存储过程sql
[pre]create procedure set_death_age(poet VARCHAR2, poet_age NUMBER);
poet_id NUMBER;
begin
SELECT id INTO poet_id FROM poets WHERE name = poet;
INSERT INTO deaths (mort_id, age); VALUES (poet_id, poet_age);;
end set_death_age;[/pre]