cancel
Showing results for 
Search instead for 
Did you mean: 

Web dynpro java external sybase database connection?io

Former Member
0 Kudos

Simple j2ee app without web dynpro:

I am able to connect to external sybase database and run a application using jdbc 4 xa driver. I am able to execute any query or update.

In web dynpro, I can just access the data I put manually in text view or picture. I have no idea how to connect to database and how to map that database to different fields. Please help.

I am using sybase as external database to which I am able to connect from Netweaver Developer studio (NWDS) in datasource explorer.

I am aware of code DataSource ds = (DataSource) context.lookup("java:comp/env/jdbc/MyAlias") that is to be put in component controller after creating datasource in nwa. But I think I am missing some steps in between.

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I found some solution to my problem.

If you want to connect to external database using sap web dynpro java Netweaver 7.3?

(Netweaver should be ABAP+JAVA - Download Netweaver 7.3 CE environment approx 5 GB, which contain a linux VMware image with all configuration needed)

There are two ways I know (for now)

1. Creating Datasource from (http://host:50000/nwa)...application resources

2. Making DC using your jar file, including the class in web dypro java file of your program

1. Creating Datasource from (http://host:50000/nwa)...application resources

->First download your database connection driver jar file from

->Go to http://host:50000/nwa then aplication resources

->Create new jdbc by uploading the jar file

->create a custom datasource

    ->choose your newly created driver

    ->There was problem in using jdbc2.0 with xa so try to use jdbc1.0 without xa

      ->leave object factory field empty

      -> for url and class path refer http://www.redmountainsw.com/wordpress/2009/08/08/jdbc-connection-urls/

http://www.redmountainsw.com/wordpress/2009/08/08/jdbc-connection-urls/  -> give a datasource alias name

  -> save

Now in your web dynpro application open the view with which you want to query database) in java editor by rightclick->open->open in java editor

(above process is done in web dynpro view of netweaver devlopment studio)

If you just want to make a query in database through that application (refer http://scn.sap.com/people/anilkumar.vippagunta2/blog/2007/02/20/reading-and-writing-images-from-sqls...)

or you can just put following code in wd.init()

try{

                Context ctx = new InitialContext();

                DataSource ds = (DataSource) ctx.lookup("jdbc/<your database alias name>");

                Connection con=ds.getConnection();

                Statement st=con.createStatement();

                wdComponentAPI .getMessageManager().reportSuccess("Executed sucesfully");

                } catch(Exception e) {

                          wdComponentAPI.getMessageManager() .reportWarning( e.toString() ); }

to remove errors click source menu->organize imports

2. Making DC using your jar file, including the class in web dypro java file of your program

For Second process I tried many times and was successful in getting external sybase connection but Now I can not do the same for other database becouse I don't know the exact step by step process

The problem is importing external database connection driver jar package. I tried adding jar file in java build path->libraries but I get the error package com.sybase.jdbc4.jdbc not available error while deploying.

I didn't understand making DC's and adding jar to public part.If anyone know step by step process to use external jar file, please reply


Answers (1)

Answers (1)

junwu
Active Contributor
0 Kudos

i don't think there is any step missing there.....