cancel
Showing results for 
Search instead for 
Did you mean: 

having problems connecting to a SQL DB

Former Member
0 Kudos

Hi all,

I'm using webdynpro and i need to connect to a db.

the line below throghs the Exception ClassNotFoundException.

Class.forName("com.sap.dbtech.jdbc.DriverSapDB");

I have imported thre jar sapDB.jar what else can i do?

I want to connect to an sql DB via java and i stack.

need your help,

Yoav

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Yoav,

I belive you put the database access codes in your Web Dynpro's implementation. In this case you need to have your JDBC driver deployed as shared library to the server. You also need to define the Library Reference in your Web Dynpro's project properties.

However, this is not a good approach and Web Dynpro never intends for business process development. You should have an EJB wrapped your database access. Then import this EJB as a model in Web Dynpro to preserve the MVC separation. Always remember Web Dynpro is an UI development tool and not for business process.

Regards,

Marc

Former Member
0 Kudos

Hi Marc,

Thank for trying to help but I knew it is not the right way.

anyhow it will be great if you'll help me find a simple example of building EJB for that perpose.

and thank once again,

Yoav

Answers (1)

Answers (1)

Former Member
0 Kudos

Another approach would be to use the container (SAP J2EE Engine's) datasources. You can configure datasources via the Visual Administrator tool of the SAP J2EE Engine (or use an Alias on the existing WebAS database). Than lookup this DataSource from the JNDI context.

Regards

Bruno

Former Member
0 Kudos

Hi Bruno,

If you have an example fot that it would be great/

Thanks Ahead,

Yoav

Former Member
0 Kudos

Yoav check out this link

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

Basically you would then use something like

DataSource ds = (DataSource) context.lookup("java:comp/env/jdbc/MyAlias")

if I recall correctly

Thanks

Bruno

detlev_beutner
Active Contributor
0 Kudos

Hi Yoav,

just in addition to the hints Bruno gave look at this https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/working with database tables in open sql for java.pdf especially pages 17-27 (and around).

If one likes SQLJ / OpenSQL is a matter of taste and working brain but anyhow, the steps to access / reference a datasource are now standardized within NWDS, that's at least an approvement compared to the old 6.20 way. On the other hand, creating DataSources (if you don't want to use the default DataSource) stays within VisualAdmin, you can access infos about this from Brunos link given (Managing Aliases -- Creating a Datasource...).

Hope it helps

Detlev