on 08-25-2008 10:38 AM
Hi all.
I created One java dictionary table. Now i want to get results from that table to Web Dynpro application.
Pl anyone help me.
with regards,
Gobinath.R
Hi,
u can do this by using Ejb.
For the first step,
1) you have to create table in the dictionary project
2) create EJB (by j2ee prespective) here entity beans is used for accessing database tables i,e. dictionary tables in this case.
3)Refer the name of the table in persistent.xml
4)write your business method in session bean and refer the name of entitybean in JNDI name.
5)call the sessionbean method from the command bean and the commandbean method from the webdynpro perspective
There are some links...
EJBs in Web Dynpro Application Using Wrapper Class
Using EJBs in Web Dynpro Applications
Accessing database table using EJB and web dynpro
Creating a J2EE-Based Car Rental Application
http://help.sap.com/saphelp_nw70/helpdata/EN/70/13353094af154a91cbe982d7dd0118/frameset.htm
Regards.
Abhilasha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
You should follow the SAP Recommended way to Work with DATA base in WD ,Which is mentioned in the Tutorial link
Also you can follow a brief step wise step procedure you can use this as workaround or mold it with the Abobe tutorial Methodology, This deals with SAP Web AS DB:--
1:-first create a web module project.
2:-create enterprise application module project.when the project is created in the j2ee project explorer pane right click on project name a context menu will come up select the first option META_INF/data -source-aliases.
3:-give any valid name to your datasource alias. and save it.
4:-and enter the name of your datasource alias name in web.xml of your web moudule .open web.xml and click on resoure tab, add new resource entry like this :--jdbc/
5.build and create web archive.
6.add the web module in your enterprise application project which you have already created.
7.build and create enterprise archive . and deploy it on WAS. make sure that it is successfully deployed.
8. now the next step is creation of database create a New dictionary project from the new submenu.
9.select database table from the hierarchy and click create new tables from the context menu.Give a name and finish. define your fields and save it.when its done click on the table name u have just created , choose generate ddl script from the context menu Select max db and after that deploy it on the server.
10.now the next step is establish a connection here datasource alias will come into the picture.
11. simplest procedure is create a web dynpro project and design your screen according the tables and write all the methods for database connectivity,retrieval and modification in componant controller .and access it from your views.
10.here is the code for establishing connection.
public java.sql.Connection getConnection( )
{
//@@begin getConnection()
try {
InitialContext init = new InitialContext();
Object obj = (Object) init.lookup("jdbc/<datasourcename>");
DataSource ds =
(DataSource) PortableRemoteObject.narrow(obj, DataSource.class);
con = ds.getConnection();
return con;
} catch (Exception e) {
System.out.println("Error in connection " + e.getMessage());
return null;
}
//@@end
}
12.for inserting updating and selecting u can write similar methods.
public java.sql.ResultSet selectEmpdata( java.lang.String Field1, java.sql.Connection con1 )
{
//@@begin selectEmpdata()
ResultSet rs = null;
try {
PreparedStatement st1 =
con1.prepareStatement(
"select field1,field2 from table_name where field1='"value"'");
rs = st1.executeQuery();
// while (rs.next())
// {
// wdComponentAPI.getMessageManager().reportSuccess("col1"+rs.getString(1));
// wdComponentAPI.getMessageManager().reportSuccess("col2"+rs.getString(2));
// wdComponentAPI.getMessageManager().reportSuccess("col3"+rs.getString(3));
// }
} catch (Exception e) {
wdComponentAPI.getMessageManager().reportException("component"+e.getMessage(),true);
return null;
}
return rs;
//@@end
}
so these are the complete steps for developing a sample database application with SAP DB.
Regards,
Siddharth
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.