cancel
Showing results for 
Search instead for 
Did you mean: 

Native SQL Query

Former Member
0 Kudos

Hi All,

I am trying to write Native SQL queries using Open sql data source . I found the following code in sap help , but i am not able to find appropriate JAR file for com.sap.sql.NativeSQLAccess , can some one tell me what is the JAR file

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);

. . .

}

Accepted Solutions (0)

Answers (3)

Answers (3)

nikhil_bose
Active Contributor
0 Kudos

Go to Web Dynpro Explorer, from your context menu select properties

Go to Java Build path

click on Add variable

Select ECLIPSE_HOME click on extend

under plugins find com.sap.opensql_2xx

select opensqlsta.jar under lib and click ok

Now, you can use the code

nikhiL

Former Member
0 Kudos

Hello Raj,

Go through this link;

Connecting to Oracle DB using Java WD

https://www.sdn.sap.com/irj/sdn/wiki?path=/pages/viewpage.action&pageid=45572

In your case; you can see and include Jar files using the Package Explorer Window, where select your project, right click and select the Set Additional Libraries and you will find the Jar files there( opensql).

Regards

Vinod V

Former Member
0 Kudos

Hi Raj,

I have no idea what this class does but you can find the same in \usr\sap\<Your instance>\JC00\j2ee\configtool\lib\opensqlsta.jar.

thanks & regards,

Manoj