Native SQL Access
Use
In exceptional cases it may be necessary to program nonportable SQL statements that exceed the scope of the Open SQL/JDBC language. For this purpose, the help class com.sap.sql.NativeSQLAccess is provided.
Features
Using the static method NativeSQLAccess.getVendorID(Connection conn) , you can determine the underlying database vendor. You use this method to ensure that a nonportable SQL statement is issued on the corresponding database platform only.
The NativeSQLAccess class offers three options for issuing a nonportable SQL statement:
-
NativeSQLAccess.createNativeStatement() - generates an object of the class java.sql.Statement .
-
NativeSQLAccess.prepareNativeStatement() - generates an object of the class java.sql.PreparedStatement .
-
NativeSQLAccess.prepareNativeCall() - generates an object of the class java.sql.CallableStatement (a Stored Procedure is called).
The following code snippet is an example of database-specific coding (where conn is a database connection object that already exists):