为什么对存储过程的JDBC调用将调用用大括号括起来? [英] Why do JDBC calls to stored procedures wrap the call in curly brackets?

查看:100
本文介绍了为什么对存储过程的JDBC调用将调用用大括号括起来?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java中,我们将执行以下操作: stmt.execute("SELECT * FROM users"); 但是对于像这样的存储过程: stmt.execute("{CALL createUser(?,?,?,?)}");

From Java we'd do something like: stmt.execute("SELECT * FROM users"); But for a stored procedure like: stmt.execute("{CALL createUser(?,?,?,?)}");

为什么普通SQL中不需要{}?

Why do we need the { and } when this is not required in normal SQL?

推荐答案

大括号是存储过程的转义语法.当JDBC驱动程序遇到{call createUser(?,?,?,?)}时,它将将此转义语法转换为数据库用来调用存储过程的本机SQL.

The curly braces are the escape syntax for stored procedures. When the JDBC driver encounters {call createUser(?,?,?,?)} , it will translate this escape syntax into the native SQL used by the database to call the stored procedure.

这篇关于为什么对存储过程的JDBC调用将调用用大括号括起来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆