cancel
Showing results for 
Search instead for 
Did you mean: 

MS SQL Database Access -> Help me

Former Member
0 Kudos

Dear all,

Can any one provide me an example project that is accessing (not SAPDB)database ?.

Help me in,

I have the general concepts regarding JDBC , that includes creation of Data Source Name.(Oracle & Aceess).

(using JDBC - ODBC Bridge.)

As like DSN , what is the equivalent in WAS(through Visual Administrator).

And how can i use that "equivalent in WAS " programmatically for data access. Exactly i dont have much concepts about that.

So kindly help me with suitable examples , or links regarding that..

with regards

Kishor .G

Accepted Solutions (0)

Answers (1)

Answers (1)

Vlado
Advisor
Advisor
0 Kudos

Hi Kishor,

You can follow the simple steps below:

1) Create a DataSource in the Visual Admin tool

http://help.sap.com/saphelp_nw04/helpdata/en/b0/6e62f30cbe9e44977c78dbdc7a6b27/frameset.htm

2) Create an EJB project, write a simple session bean and declare a resource reference to the DataSource

http://help.sap.com/saphelp_nw04/helpdata/en/b5/3f533e5ff4d064e10000000a114084/frameset.htm

http://help.sap.com/saphelp_nw04/helpdata/en/64/8590109a86f145958fb22dab86d58d/frameset.htm

3) Create a simple JSP that accesses the session bean

http://help.sap.com/saphelp_nw04/helpdata/en/7d/cf0c8abcc34594ba9d3bbd5dd22155/frameset.htm

http://help.sap.com/saphelp_nw04/helpdata/en/85/496adae9bf40b09653239e9c58f9b0/frameset.htm

4) Build the archives, deploy and run the application

http://help.sap.com/saphelp_nw04/helpdata/en/7f/5c93acbd1343d4be7d79dc298faa7b/frameset.htm

http://help.sap.com/saphelp_nw04/helpdata/en/5c/a3400ed0c6411bbaa5506cce1dbfc9/frameset.htm

The code in the session bean that accesses the DB should look like:


InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:comp/env/<res-ref-name>");
Connection conn = null;
try {
    conn = ds.getConnection();
    //do some work thru conn
} finally {
    conn.close();
}

If you have a more complex scenario with DB access, you may consider developing CMP entity beans, O/R mapping, relationships, using EJB QL queries, and so on... You can find exhaustive help starting from <a href="http://help.sap.com/saphelp_nw04/helpdata/en/f6/6a9266482d114f9b3e312768578c94/frameset.htm">here</a>.

Hope that helps,

Vladimir