Java 我想从jdbctemplate调用存储过程,需要在存储过程中生成pk
在java类中Java 我想从jdbctemplate调用存储过程,需要在存储过程中生成pk,java,spring,stored-procedures,jdbctemplate,Java,Spring,Stored Procedures,Jdbctemplate,在java类中 Create procedure College.Create_Student @Roll Number VARCHAR(7) = NULL, @Name VARCHAR(35) = NULL, @Phone VARCHAR(10) = NULL, @Email VARCHAR(20) = NULL # Insert into Student Table and return the primary ke
Create procedure College.Create_Student
@Roll Number VARCHAR(7) = NULL,
@Name VARCHAR(35) = NULL,
@Phone VARCHAR(10) = NULL,
@Email VARCHAR(20) = NULL
# Insert into Student Table and return the primary key
我正在尝试获取存储过程中生成的主键。请帮忙
PS:我是第一次这样做。对于简单的过程,您可以使用jdbcTemplate的更新方法:
String sql = "{call college.create_student(?,?,?,?)}";
String studentUniqueNum = jdbcTemplate.queryForList(sql,
new Object[] { roll_num,name,phone,email},String.class);
此方法将返回您的主键。对于简单的过程,您可以使用jdbcTemplate的更新方法:
String sql = "{call college.create_student(?,?,?,?)}";
String studentUniqueNum = jdbcTemplate.queryForList(sql,
new Object[] { roll_num,name,phone,email},String.class);
此方法将返回您的主键。实现此方法的步骤
谢谢你的回答,但那不是我想要的。经过这么多的搜索。。。我在store过程中寻找一个带有输出参数的答案,以及如何使用JDBCTemplate在java中检索它。谢谢你的答案,但这不是我想要的。经过这么多的搜索。。。我正在寻找存储过程中带有输出参数的答案,以及如何在java with jdbctemplate中检索它