Skip to Content
avatar image
Former Member

Native SQL

Hi,

How do you write Native SQL commands for a datasource whose SQL Engine type is Open SQL. For Eg: i have a datasource MyDS with SQL Engine type as Open SQL. For a connection "conn" to this datasource i cannot use methods like

conn.createStatement(int,int) as it is not supported by open sql.

Thanks in advance

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • avatar image
    Former Member
    Jun 13, 2007 at 05:05 AM

    Hi,

    Check this link this maybe helpful to you

    http://help.sap.com/saphelp_nw04/helpdata/en/51/ef9f94e4ba894d8e93b2eed7c9f82d/frameset.htm

    Regards,

    SURYA

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 13, 2007 at 05:15 AM

    Using the static method NativeSQLAccess.getVendorID(Connection conn), you can determine the underlying database vendor. You use this method to ensure that a non-portable SQL statement is issued on the corresponding database platform only.

    The NativeSQLAccess class offers three options for issuing a non-portable 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).

    import java.sql.PreparedStatement;

    import com.sap.sql.NativeSQLAccess;

    String mssOnlyStmt = "…";

    // ensure correct process environment

    if (NativeSQLAccess.getVendorID(conn) !=

    NativeSQLAccess.VENDOR_MS_SQL_SERVER) {

    // error handling

    } else {

    // variant 1

    PreparedStatement ps =

    NativeSQLAccess.prepareNativeStatement(

    conn, mssOnlyStmt);

    . . .

    // variant 2

    Statement stmt =

    NativeSQLAccess.createNativeStatement(conn);

    int result = stmt.execute(mssOnlyStmt);

    . . .

    // variant 3

    CallableStatement cs =

    NativeSQLAccess.prepareNativeCall(

    conn, mssOnlyStmt);

    . . .

    }

    And also see this link..

    http://help.sap.com/saphelp_nw04/helpdata/en/bb/d604ad96d444bfa6cb15652d44b2a8/frameset.htm

    Urs GS

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 13, 2007 at 05:25 AM
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 13, 2007 at 05:35 AM
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 13, 2007 at 05:50 AM

    i have gone thru the links tht u have mentioned. it requires some additional JARs for the same. Trying to find out wat JARs are reqd and where will i get it from ?

    Add comment
    10|10000 characters needed characters exceeded