jdbc调用存储过程。 JDBCSQL
程序员文章站
2022-07-12 10:55:37
...
基本上没用过,快忘记了。
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]
上一篇: Arduino,ESP32-CAM EEPROM操作
下一篇: ESP32-cam SD卡读写图片