轉義語法可讓您使用特定於資料庫的功能,這些功能無法透過使用標準的JDBC方法和屬性來實現。
一般的SQL轉義語法格式如下:
{keyword 'parameters'}
Following are various escape syntaxes in JDBC:
d, t, ts Keywords: They help identify date, time, and timestamp literals. As you know, no two DBMSs represent time and date the same way. This escape syntax tells the driver to render the date or time in the target database's for| yyyy = year, mm = month; dd = date. Using this syntax {d '2009-09-03'} is March 9, 2009.
Example
{d 'yyyy-mm-dd'}
//Create a Statement object stmt = conn.createStatement(); //Insert data ==> ID, First Name, Last Name, DOB String sql="INSERT INTO STUDENTS VALUES" + "(100,'Zara','Ali', {d '2001-12-16'})"; stmt.executeUpdate(sql);
##fn Keyword
to get the length of a string −##
String sql = "SELECT symbol FROM MathSymbols WHERE symbol LIKE '\%' {escape '\'}"; stmt.execute(sql);
{fn length('Hello World')}
{call my_procedure(?)};
{? = call my_procedure(?)};
{oj outer-join}
String sql = "SELECT Employees FROM {oj ThisTable RIGHT OUTER JOIN ThatTable on id = '100'}"; stmt.execute(sql);
以上是JDBC SQL轉義語法是什麼意思?請解釋一下的詳細內容。更多資訊請關注PHP中文網其他相關文章!