BC4J: How get Connection from Application Module
I've written a custom method for my Application Module for using by the client tier. In this method I call a JPUblisher created class, that accesses a PL/SQL procedure. For this JPublisher created class I need a connection context. The class calls DefaultContext.getDefaultContext() but that seems to be null.
How can I get the current Connection of the Application Module, so that I can create a DefaultContext?
Unfortunately Transaction has no getConnection method.
Thanks,
Robert
We don't make the Connection directly available because in some sense it's a rope on which you can hang yourself if you are not careful. Since BC4J AppModules are most often used from a pool, and you might be using connection pooling in addition to application module pooling, in general it is not safe to get hold of the raw JDBC connection and "hang onto it".
If you make careful use to always get the current JDBC connection before you use it, and not try to cache it, then you should be ok. Often, you can avoid the need to get the raw JDBC connection by calling getDBTransaction().createPreparedStatement(...) or the analogous createCallableStatement() or createStatement() that are also on the DBTransaction interface.
Here is a little function you can add to your application module impl class to retrieve the Connection:
private Connection getCurrentConnection() {
Statement st = null;
try {
st = getDBTransaction().createStatement(0);
return st.getConnection();
catch (SQLException s) {
s.printStackTrace();
return null;
finally {
if (st != null) try { st.close(); } catch (SQLException s2) {}
}It basically creates a (dummy) statement, gets the current connection from the statement, then closes the statement.
I tried using this in a custom method in an AppModuleImpl class that invoked a JPublisher-create package-wrapper class like this:
public void callStoredProc() {
try {
// Empservice is package wrapper class created by JPublisher
Empservice e = new Empservice(getCurrentConnection());
BigDecimal sal = e.lookupsalary(new BigDecimal(7369));
System.out.println(sal);
catch (SQLException s) {
s.printStackTrace();
}and it works for me.
Similar Messages
-
Obteain connection object from application module
Hello
I am working with ADF 10g using BC4j , I am in application module implementation class, how can I obtain the java.sql.connection object used by my application module?to execute prepared statements follow
http://download-uk.oracle.com/docs/html/B25947_01/bcadvgen005.htm#sm0297
to access the SQL connection itself (for whatever reason)
Re: how to get connection from adf bc?
Frank -
HOW COULD CONNECT FROM SAP SYSTEM TO THIRD PARTY JAVA APPLICATION
HI expects,
HOW COULD CONNECT FROM SAP SYSTEM TO THIRD PARTY JAVA or . DET APPLICATION.please provide me some scenarios and documents.please help me.Hi,
In the sender side i.e. in SAP system you can use IDoc/RFC/Proxy to push the data to XI.
IDoc supports only Async communication and in Sync case performace is good using Proxy.
In the receiver side you can use Java Proxy to connect to the Java application or you can even bulid a webservice over the Java/.Net application and use SOAP adapter to post data to it.
Thanks
SaNv... -
PL/SQL from Application Module instead of Using VO/EO - Violating Standard?
Hi,
I have seen product code which Use PL/SQL APIs for committing data (Creation of Records in Table) from Application Module. There is no BC4J (VO/EO) used in this data route.
Is there any coding standard (document) which says such cases are against Standards.I know there is one Standard saying PL/SQL Based VO is dicouraged in Oracle Apps.
Thanks
JosephVikram,
Performance depends on the way you are going to make use of pl/sql code. Suppose if you are using pl/sql just for final insert/update with other validations bound to it through a single call, that's fine. But in case you have other multiple calls to pl/sql blocks also for fetching data for display purpose, that's where standard VO's will be more efficient reducing the number of trip for pl/sql calls. So use it only when it is the last way and you need to handle multiple validations with complex data structure.
As for locking, yes, you might have to take care of locking handling scenario if such a situation happens. But again it depends on what's your business logic and how is your data being processed.
--Shiv -
Get Connection from connection pooling
Hi,
I am aware of the fact that to get connection from a connection pool we need to add JNDI name in context.xml of apache tomcat and use it in our application to get connection. I have tested this and it works fine.
Now, we have 12 servers having free database each having almost 20 small Java applications for different purposes (get data from server database do some business logic and maipulation with data from central database and store on central database) each connecting to central database.
We were enjoying life till we had almost 8-9 servers but now many times we have connection issues as there are too many connections to central database and servers are going to increase.
I know my company design is not good but we need some solution.
I want my Java applications to take database connectivity using connection pooling on servers. My Java applications are standalone applications that do not run in web server. Is this approach fine?
I searched google for some solution but was unable to find.
Any pointers would be really helpful.
I think that since my application is outside web container I am unable to get Context (java:/comp/env). Please give me some pointers on how can i get web server context outside web server.
Thanks and Regards,
Vikash Anand.Google ( [jndi standalone application|http://www.google.com/search?q=jndi+standalone+application] ).
-
Open script cannot get connection from the brower helper after 15 seconds.
Error:
===
Open script cannot get connection from the brower helper after 15 seconds. Do you want to continue waiting for the browser to load?
Please Note:
========
1. I have tried this only on IE
2. I am running OATS on a Remote desktop
Situation:
======
Trying to stop the recording
Try to get xpath of an object using Inspect Path
Setup details
========
Windows XP 5.1 Service Pack 3, x86
OpenScript 12.1.0.1.383
Internet Explorer 8.0.6001.18702
FireFox 13.0.1
Mitigation steps done till now:
==================
1. Disabled windows firewall
2. Disable XSS filter setting
3. Restarted the ATS services (3 of them)
4. Run the Open Script Diagnosis Tool (PS: There are 3 errros even after running it. The 3 errros are listed in the workspace_log log file snippet below...)
Error in worspace_log:
=============
To Change setting:
Go to Tools > Internet Options and Choose Security Tab
Select the Zone to modify and Press Custom level
Find Enable XSS filter Setting - Select Disable and click Ok
!ENTRY oracle.oats.scripting.diagnosisTool.api.DiagnosisExecutor 4 0 2012-07-09 17:08:52.594
!MESSAGE Failure found when diagnosing Oracle EBS/Forms Load Testing Forms LT Diagnoser
!ENTRY oracle.oats.scripting.diagnosisTool.api.DiagnosisExecutor 4 0 2012-07-09 17:08:52.594
!MESSAGE Did not auto-fix the problem.
!ENTRY oracle.oats.scripting.diagnosisTool.api.DiagnosisExecutor 4 0 2012-07-09 17:08:52.594
!MESSAGE Suggestion for fixing: Please change your Java proxy setting to Use Browser Settings
Aprreciate help on this.To resolve this, you need to reconfigure the "Oracle Application Testing Suite Helper Service" (OATSHelperSvr) to start as a user who has privledges to run open script tests rather than the default SYSTEM user.
Reconfiguring the OATSHelperSvr Service:
1. Open the services panel (Start > Run > services.msc)
2. Find the Oracle Application Testing Suite Helper Service
3. Right Click > Properties then select the Log On Tab
4. Specify an interactive user that has rights to run OpenScript (test by logging in as that user and running tests):
5. Click OK
6. Restart the service after dialogs are closed by Right Click > Restart
7. You should now repeat this process for the "Oracle Application Testing Suite Agent Service" (eLoadAgentMon) Service (Two services in
total)
You should now retry running the test in Oracle Test Manager -
Call VO method from application module
Hi Experts.
In my case I have created VO and inside implementation class custom method: filterResultsByGroup()
code:
public class VO_Business_AreaImpl extends ViewObjectImpl implements VO_Business_Area {
public VO_Business_AreaImpl() {
public void filterResultsByGroup() {
System.out.println("hello");
now... I would like to call filterResultsByGroup() method from Application Module Imp class:
code:
public class AppModuleImpl extends ApplicationModuleImpl implements AppModule {
public AppModuleImpl() {
public VO_Business_AreaImpl getVO_Business_Area1() {
return (VO_Business_AreaImpl)findViewObject("VO_Business_Area1");
public void RunGroupFilter(){
ViewObjectImpl bussinesArea;
bussinesArea = this.getVO_Business_Area1();
ViewCriteria vc = bussinesArea.getViewCriteria("filterResultsByGroup();");
bussinesArea.applyViewCriteria(vc);
bussinesArea.executeQuery();
but it doesn't work. Anyone knows how to call this method?
Best Regards.you code should be like
VO_Business_AreaImpl bussinesArea;
bussinesArea = this.getVO_Business_Area1();
bussinesArea.filterResultsByGroup(); -
How could the Oracle Application Module Browser collect all the interfaces?
How could the Oracle Application Module Browser comes with the Oracle AS Adapter collect all the interfaces that are available through Oracle Integration Repository? Is it from the XML description file in the Oracle Integration Repository?
Thanks,
QingDid you ever figure this out? I'm encountering the same issue.
Thanks. -
Weblogic realm authentication failure getting connection from pool
We are getting this error when we try to get a connection from the
pool for a Tx Data Source. We are successfully getting connections
from a (non-Tx) Data Source.
java.lang.SecurityException: Authentication for user Fitness_demo
denied in realm weblogic
at weblogic.security.acl.Realm.authenticate(Realm.java:212)
at weblogic.security.acl.Realm.getAuthenticatedName(Realm.java:233)
at weblogic.security.acl.internal.Security.authenticate(Security.java:125)
at weblogic.security.acl.Security.doAsPrivileged(Security.java:481)
at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:127)
We have added the DB user as a user in the realm, which usually does
the trick; but in this case it does not. We are using Merant's
JSQLConnect type 2 driver for SQL Server, and we are running on
Solaris. The scenario works fine using Oracle Thin driver on Windows.
Do we need ACL entries or something? We do not have any ACL entries
now.
Thanks,
-wesWe are getting this error when we try to get a connection from the
pool for a Tx Data Source. We are successfully getting connections
from a (non-Tx) Data Source.
java.lang.SecurityException: Authentication for user Fitness_demo
denied in realm weblogic
at weblogic.security.acl.Realm.authenticate(Realm.java:212)
at weblogic.security.acl.Realm.getAuthenticatedName(Realm.java:233)
at weblogic.security.acl.internal.Security.authenticate(Security.java:125)
at weblogic.security.acl.Security.doAsPrivileged(Security.java:481)
at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:127)
We have added the DB user as a user in the realm, which usually does
the trick; but in this case it does not. We are using Merant's
JSQLConnect type 2 driver for SQL Server, and we are running on
Solaris. The scenario works fine using Oracle Thin driver on Windows.
Do we need ACL entries or something? We do not have any ACL entries
now.
Thanks,
-wes -
How to connect from VC++ 6.0 to Oracle 8i
Can anybody tell me how to connect from
VC++ 6.0 to Oracle 8i which is installed
in server (without installing in client)Whats the problem you are facing, from what I see its pretty straight forward. Edit the system object, from 'Show Category' drop down select Internet Transaction Server, hit the modify button at the extreme right and your good to go.
Thanks,
GLM -
Problem to get Connection from JBoss AS
PLEASE HELP ME....
I GOT ERROR WHILE I TRYED TO GET A CONNECTION FROM JBOSS APP. SERVER.
THE CODE IS
package com.beo.atlas.common;
public final class ServiceLocator {
private static final String JBOSS_INITIAL_CONTEXT_FACTORY = "org.jnp.interfaces.NamingContextFactory";
private static final String JBOSS_PROVIDER_URL = "localhost:8080";
private static final String JBOSS_URL_PKG_PREFIXES = "org.jboss.naming:org.jnp.interfaces";
public static final String ATLAS_DATASOURCE = "java://myatlasdbpool";
private static java.util.Hashtable dataSourceCache = null;
private static ServiceLocator locator = null;
static {
System.out.println("Locator Initializing");
dataSourceCache = new java.util.Hashtable();
locator = new ServiceLocator();
private ServiceLocator() { }
public static ServiceLocator newInstance() {
System.out.println("Returning the Locator Object");
return locator;
public java.sql.Connection getDBConnection() throws java.sql.SQLException,javax.naming.NamingException {
System.out.println("Getting Data base Connection....");
if(dataSourceCache.containsKey(ATLAS_DATASOURCE)) {
System.out.println("Trying to get Connection from CACHE...");
System.out.println("Returning Connection Object from cache.");
return (java.sql.Connection)dataSourceCache.get(ATLAS_DATASOURCE);
System.out.println("FAILED to get Connection from CACHE");
System.out.println("Trying to create new Connection...");
java.util.Properties props = new java.util.Properties();
props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,JBOSS_INITIAL_CONTEXT_FACTORY);
props.put(javax.naming.Context.PROVIDER_URL,JBOSS_PROVIDER_URL);
props.put(javax.naming.Context.URL_PKG_PREFIXES, JBOSS_URL_PKG_PREFIXES );
javax.naming.InitialContext context = new javax.naming.InitialContext(props);
Object o = context.lookup(ATLAS_DATASOURCE);
System.out.println("Object Created...");
javax.sql.DataSource dataSource = null;
try {
dataSource = (javax.sql.DataSource)javax.rmi.PortableRemoteObject.narrow(o,javax.sql.DataSource.class);
}catch(Exception e) {
java.sql.Connection con = dataSource.getConnection();
dataSourceCache.put(ATLAS_DATASOURCE,con);
System.out.println("Returning new Connection Object.");
return con;
ERROR
Locator Initializing
Returning the Locator Object
Getting Data base Connection....
FAILED to get Connection from CACHE
Trying to create new Connection...
Object Created...
java.lang.ClassCastException
at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(Unknown S
ource)
at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at com.beo.atlas.common.ServiceLocator.getDBConnection(ServiceLocator.ja
va:56)
at AtlasClient.printData(AtlasClient.java:16)
at AtlasClient.main(AtlasClient.java:8)
Caused by: java.lang.ClassCastException: org.jnp.interfaces.NamingContext
... 5 moreI've got the same problem. Working with JBoss 4.0.3 and Tomcat 5.5. The lookup goes fine and returns an object of type remote home, however when I perform the narrow() I get ClassCastException. I'm sure the client and the server have got the same file version as I built from the same source.
[error]
Caused by: java.lang.ClassCastException
at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
[error] -
How to connect webdynpro application to database (Sql server)
Hi Experts,
Can someone suggest me how to connect webdynpro application to SQL Server. (Possibly in detail)
Thanks Regards,
Sandeephi sandeep,
here is a sample code which connects to a backend database Oracle; Connection is same for all DBs as you are using open sql commands.
<b> try {
String eposta = wdContext.currentContextElement().getEposta();
String tel = wdContext.currentContextElement().getTelefon();
String company = wdContext.currentContextElement().getCompany();
String message = " ";
String onerikonusu = " ";
String oneri_mdurum = " ";
String oneri_odurum = " ";
String oneri_bfaydalar = " ";
String oncelik1 = " ";
String uygulama = " ";
String tarih = (new SimpleDateFormat("dd-MM-yyyy").format(new java.util.Date()));
String saat = (new SimpleDateFormat("HH:mm:ss").format(new java.util.Date()));
//java.sql.Date tarih = java.sql.Date.valueOf(creationDate);
//java.sql.Time saat = java.sql.Time.valueOf(creationTime);
if (wdContext.currentContextElement().getMesaj() != "")
{ message = wdContext.currentContextElement().getMesaj(); }
if (wdContext.currentContextElement().getOneri_konusu() != "")
{ onerikonusu = wdContext.currentContextElement().getOneri_konusu(); }
if (wdContext.currentContextElement().getOneri_mdurum() != "")
{ oneri_mdurum = wdContext.currentContextElement().getOneri_mdurum(); }
if (wdContext.currentContextElement().getOneri_konusu() != "")
{ oneri_odurum = wdContext.currentContextElement().getOneri_odurum(); }
if (wdContext.currentContextElement().getBekfaydalar() != "")
{ oneri_bfaydalar = wdContext.currentContextElement().getBekfaydalar(); }
if (wdContext.currentContextElement().getOncelik() != "NULL")
{ oncelik1 = onceliktxt.toUpperCase(); }
if (wdContext.currentContextElement().getUygulama() != "NULL")
{ uygulama = app.toUpperCase(); }
InitialContext ctx = new InitialContext();
javax.sql.DataSource ds =
(javax.sql.DataSource) ctx.lookup("jdbc/SAPEPPDB");
java.sql.Connection con = ds.getConnection();
con.setAutoCommit(false);
java.sql.Statement stmt = con.createStatement();
String sql;
int rows;
sql = "insert into tmp_feedbacks " +
"(puid, name, tel, email, company, konu, oncelik, uygulama, mesaj, onerikonusu," +
"oneri_mdurum, oneri_odurum, oneri_bfaydalar,tarih,saat) " +
"values ('" + username + "', " +
"'" + name + "'," +
"'" + tel + "'," +
"'" + eposta + "'," +
"'" + company + "'," +
"'" + konutxt.toUpperCase() + "'," +
"'" + oncelik1 + "'," +
"'" + uygulama + "'," +
"'" + message + "'," +
"'" + onerikonusu + "', " +
"'" + oneri_mdurum + "', " +
"'" + oneri_odurum + "', " +
"'" + oneri_bfaydalar + "', " +
"'" + tarih + "', " +
"'" + saat + "' " +
stmt = con.createStatement();
rows = stmt.executeUpdate(sql);
con.commit();
stmt.close();
catch(Exception e){
IWDMessageManager msgMgr =
wdComponentAPI.getMessageManager();
msgMgr.reportException(e.getMessage(),true);
}</b>
The value <b>ctx.lookup("<jdbc_pool>");</b> depends on your system id.
if your system id is SID the the string has to be <b>jdbc/SAPSIDDB</b>
you can check it via visual admin >> server >> services >> jdbc con. -
How to connect from bw system ecc system.
how to connect from bw system ecc system.
Solution
Maintain the entry using the following path:
Call Administrator workbench (transaction RSA1).
From the 'Settings' menu, select Global Settings'.
If an entry already exists in the field "BW user for ALE", delete this.
Enter the correct names for the BW users in this field.
Save the entry.
You must restart the Administrator Workbench (RSA1) now.
The source system can now be linked without errors.
hope this helps. -
How to connect from java without using oracle client installation
hi ,
Please tell me how to connect from java without using oracle client
Thanks & Regarshttp://www.orafaq.com/wiki/JDBC#Thin_driver
-
How get support from oracle for reports6i
how get support from oracle for reports6i
If you have support contract with Oracle, you can use this site:
http://www.metalink.oracle.com
or for more information
http://www.oracle.com/support/premier/global-support-resolution/metalink.html
Maybe you are looking for
-
Forum This is driving us a bit nuts. Is there a keyboard shortcut to finding a clip that is in the timeline, in the bin it resides in? Working with a lot of bins, it gets a bit tedious and time consuming opening each bin one by one and looking for th
-
How to open editor in oracle11
In Oracle8 if we type ed and hit Enter it opens the default editor(notepad) where can write a block or edit a query. How to use this feature in Oracle 11?
-
Photoshop stopped saving "PNG" files
Hi All... My photoshop stopped saving PNG files today. Weird! I reinstalled my software, all disc's, and it still won't save. It says there is a 'program error". Any one have any thoughts? Thanks.
-
How to create a vi project with two ao channel and multi ai channel by customer/producer mode
I'm a ni elvis ii user. i want to create one vi which include 2 AO channel output FGEN and multi AI channel acquisition signal, and i wish use cunstomer/producer mode to realize this vi. here is the vi,run this vi seveal secends,then pop-up with "完成该
-
Imovie 11 video has audio dropouts when trying to burn to iDVD or Quicktime
Please help... video is 90 minutes long in DV 4x3 format... had no problems before this, and i cannot figure it out.