on 03-25-2008 5:53 AM
Hi Experts,
I am new to webdynpro for java world.can you plese help me.....
I want to get the database connection from my webdynpro for java application. for that
I have installed CE7.1 j2ee Server with MAXDB database.
I have installed SQL Studio also.
Can you please send the details to connect to database from my java program.
If you send detailed steps it will be very very helpful for me.
Thanks in advance.
Regards,
Shashi.
Hi Shashi,
You need to use a datasource. For more information: [Application Resources Management|http://help.sap.com/saphelp_nwce10/helpdata/en/44/e3c34b4c836c2fe10000000a114a6b/frameset.htm].
HTH!
\-- Vladimir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>
> Can you please give the "CPDS Class Name"
> Driver Class Name and Database URL for SQL .
>
The values depend on the particular JDBC driver used.
>
> If possible can you please give the links to download Jdbc Driver for SQL Studio. That will be very use full for me.
>
You don't need a separate driver to connect to the system DB which as far as I understand is MaxDB in your case. You can use the system driver (and probably also the system datasource - so no need for a custom datasource either).
HTH!
\-- Vladimir
Hi,
I have DefaultDriver ="SYSTEM_DRIVER"
Default DataSource ="SAPCE1DB"
I am using following code template in wdDoInit() method to connect database
InitialContext ic = new InitialContext();
DataSource ds = (DataSource)ic.lookup("java:comp/env/SAPCE1DB");
Connection con = ds.getConnection();
Statement st = con.createStatement();
st.executeUpdate("insert into sample2 values(11)");
But i am unable to insert into sample2 table.
Can you please help me on this one.
Thanks and Regards,
Shashikiran.B
The "java:comp/env/" lookup works only for standard Java EE components, e.g. EJBs, JSPs, servlets. And besides, you have to define a reference, e.g. resource-ref, in the corresponding deployment descriptor, in order to use it, or you have to use dependency injection (@Resource).
Anyway, working with the DB directly in the UI layer (Web Dynpro) is not a good idea. You'd better consider the MVC paradigm and move the DB access code to the business layer (EJB) or use JPA instead of pure JDBC. The EJBs would be called by Web Dynpro then. Some helpful links about this:
[Importing Enterprise JavaBean (EJB) Models|http://help.sap.com/saphelp_nwce10/helpdata/en/45/dd45e4bc295595e10000000a1553f7/frameset.htm]
[Developing Business Logic with EJB 3.0|http://help.sap.com/saphelp_nwce10/helpdata/en/44/e9af22b9dc03fde10000000a1553f6/frameset.htm]
[Using JPA in the Persistence Layer|http://help.sap.com/saphelp_nwce10/helpdata/en/44/eba6292f446c30e10000000a114a6b/frameset.htm]
Regards,
\-- Vladimir
https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement
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.