Using Datasource with Toplink
Hi,
I am using toplink 10.1.3 .We are using the datasource to connect to weblogic connection pool.
My session.xml is like this:
- <login xsi:type="database-login">
<platform-class>oracle.toplink.platform.database.oracle.Oracle10Platform</platform-class>
<user-name />
<datasource>jdbc/ds</datasource>
</login>
In the java DAO part,I need a physical database connection to get the ArrayDescriptor.The part of java code is below
java.sql.Connection dbconnection=null;
DatabaseLogin login = serverSession.getLogin();
dbconnection=(java.sql.Connection)login.connectToDatasource(null);
Questions:
1.Is the above correct way to get the Physical JDBC connection from a weblogic connection pool(configured using datasource).
2.How will the Connection released to the pool?Should i use dbconnection.close() or clientSession.release().
Thanks
Thanks doug for your reply.
I am using datasource to connect to the weblogic 9.2 connection pool.
My specific use case is this.
I am executing a Stored procedure which will takes a Oracle user defined data type as an Input paramater.
some steps we use in the java code for the above use case.
--Getting the toplink session
ServerSession serverSession = TopLinkGenericDAO.getSession();
clientSession = serverSession.acquireClientSession();
--For getting the oracle user defined array
java.sql.Connection dbconnection=null;
DatabaseLogin login = serverSession.getLogin();
dbconnection=(java.sql.Connection)login.connectToDatasource(null);
oracle.sql.ArrayDescriptor descriptor = new oracle.sql.ArrayDescriptor(
"STRING_ARRAY", dbconnection);
oracle.sql.ARRAY arr_ORCL = new oracle.sql.ARRAY(descriptor,
dbconnection, aIncl_Vin);
--for executing stored procedure
StoredProcedureCall call = new StoredProcedureCall();
DataReadQuery dbquery = new DataReadQuery();
call.setProcedureName(CVeITDAOConstants.INSERT_PING);
call.addNamedArgumentValue("para1", arr_ORCL );
dbquery.setCall(call);
--release connection in the finally block
finally
clientSession.release();
dbconnection.close();
The above code fails when we execute it for 150 concurrent connection(using JMeter) with connection fail exception.
Please let me know how do i release the physical jdbc connection(dbconnection) in the finally block.
do we need to give dbconnection.close() or just by giving clientSession.release() will also release the jdbc connection.
Thanks.
Similar Messages
-
How can i using datasource in toplink's map file
In the TopLink map :
<toplink:login xsi:type="toplink:database-login">
<toplink:platform-class>oracle.toplink.platform.database.oracle.Oracle10Platform</toplink:platform-class>
<toplink:user-name>test</toplink:user-name> <toplink:password>C23487CFA591952D44310804F3D591CB</toplink:password>
<toplink:sequencing>
<toplink:default-sequence xsi:type="toplink:native-sequence">
<toplink:preallocation-size>1</toplink:preallocation-size>
</toplink:default-sequence>
</toplink:sequencing>
<toplink:driver-class>oracle.jdbc.driver.OracleDriver</toplink:driver-class>
<toplink:connection-url>jdbc:oracle:thin:@192.168.0.1:1521:testdb</toplink:connection-url>
<toplink:bind-all-parameters>true</toplink:bind-all-parameters>
</toplink:login>
How can i modify it using datasource?The login information stored in the map file is good for direct connection and design time login information.
For your runtime login information I would use the sessions configuration (sessions.xml). It provides complete deployment configuration:
<session>
<name>my-session</name>
<!-- This references the ORM map XML file -->
<project-xml>META-INF/employee-basic.xml</project-xml>
<session-type>
<server-session/>
</session-type>
<login>
<datasource>jdbc/TopLinkDS</datasource>
<uses-external-connection-pool>true</uses-external-connection-pool>
<uses-external-transaction-controller>true</uses-external-transaction-controller>
</login>
<external-transaction-controller-class>oracle.toplink.essentials.transaction.oc4j.Oc4jTransactionController</external-transaction-controller-class>
<enable-logging>true</enable-logging>
<logging-options>
<log-exceptions>true</log-exceptions>
<print-thread>false</print-thread>
<print-date>false</print-date>
</logging-options>
</session>Doug -
Using DataSource with MS Access
is it possible to use the JDBC DataSource with MS Access? Should I download some .class to register with JNDI?
I've done it with Tomcat, but I've never tried to do it outside of a container. You sound like you want to do it without a servlet or J2EE app server engine acting as the lookup and pool. - MOD
-
Using Clob with TopLink 9.0.4.5 and Oracle 10g RAC
I am trying to store an XML file in a Clob type field of a DB table using TopLink 9.0.4.5 and Oracle 10g RAC and need some guidance about how to do it. I got some directions to start it with the Tip "How-To: Map Large Objects (LOBs) to Oracle Databases with OracleAS TopLink" but still need some more helps.
When using the Oracle JDBC OCI driver, the tip gives the code block for a Clob field:
DirectToField scriptMapping = new DirectToField();
scriptMapping.setAttributeName("script");
scriptMapping.setFieldName("IMAGE.SCRIPT");
descriptor.addMapping(scriptMapping);
As I understand, TopLink creates instances of the Descriptor class at run time for each of the descriptor files and stores them in a database session, where is the proper place (in SessionEvent of TopLinkSessionEventHandler?) for me to get a reference to such an instance of my Descriptor class in Java code so that I can add the above mentioned additional Mapping? Are the above String values of "script" and "IMAGE.SCRIPT" predefined in TopLink API? Can I accomplish the same thing just using the TopLink Workbench tool instead? If yes, please advise the detailed steps to do so.
The tip also states to call the following code in case of using Clob:
DatabaseLogin login = session.getLogin();
login.useStringBinding();
Should the above 2 lines of code be called after the following lines of code?
SessionManager sessionManager = SessionManager.getManager();
Server serverSession = (Server)sessionManager.getSession("MY_SESSION_NAME");
Besides the above extra coding for the Session and Descriptor Mapping, is there any special handling in between Data model and DB table mapping? Can I map a Java String type to a DB Clob field using the Direct-to-field mapping?
Appreciate any help.Never mind ....... I had already figured it out .....
-
Using datasource with streaming api inside a web service
I am using the 9.1 server and accessing a datasource
created with aldsp3.0. When I run the code below as a
standalone java app, everything works fine. When I run it
on the server, I get a class cast exception when trying to cast an object returned from the stream to MyData type.
When running the java app in the debugger, the objects
dataServiceDoc, dog , and dObj all have
the correct type. When running the web service in the debugger, the objects are all of type
DataObjectGeneral, thus causing the cast error.
<p><p>
Any help will be greatly appreciated!
<p>
Thanks.
<p><p>
package services;
<p>
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import weblogic.jndi.Environment;
import com.bea.dsp.RequestConfig;
import com.bea.dsp.das.DASResult;
import com.bea.dsp.das.DataAccessServiceFactory;
import com.bea.dsp.das.PreparedExpression;
import com.bea.sdo.impl.data.DataObjectGeneral;
import commonj.sdo.DataObject;
<p>
@WebService
<p>
public class MyService
<p>
private final static String DS_URL = "t3://localhost:7001";
<p>
@WebMethod
<p>
public String testMethod2()
<p>
StringBuilder result = new StringBuilder();
<p>
try
<p>
// Get the initial context to the WebLogic Server passing in user credentials
<p>
Context ctx = getInitialContext(DS_URL,"weblogic", "weblogic");
<p>
RequestConfig reqConfig = new RequestConfig();
<p>
reqConfig.enableFeature(RequestConfig.RETURN_DATA_SERVICE_AUDIT);
<p>
reqConfig.enableFeature(RequestConfig.RETURN_AUDIT_PROPERTIES);
<p>
reqConfig.setStringArrayAttribute(RequestConfig.RETURN_AUDIT_PROPERTIES,
new String[] { "common", "query" });;
<p>
String dspDataSpace = "MY_DS";
<p>
String adhoc = createQuery();
<p>
PreparedExpression pe = DataAccessServiceFactory.prepareExpression(ctx, dspDataSpace, adhoc);
<p>
DASResult<Object> dasResult = pe.executeQuery(reqConfig);
<p>
int i = 0;
<p>
int N = 100;
<p>
Long[] ids = new Long[N];
<p>
while (dasResult.hasNext() && i<N)
<p>
Object dataServiceDoc = dasResult.next();
<p>
// Convert Object to a Data Object
<p>
DataObjectGeneral dog = (DataObjectGeneral) dataServiceDoc;
<p>
DataObject dObj = dog.getRootObject();
<p>
// Cast the Data Object to the SDO Type (MyDataType)
<p>
MyDataType p = (MyDataType) dObj;
<p>
i++;
<p>
<p>
catch (Exception e)
<p>
result.append(e);
<p>
<p>
return result.toString();
<p>
<p>
private static InitialContext getInitialContext(String url, String username, String password) throws NamingException
<p>
Environment env = new Environment();
<p>
env.setProviderUrl(url);
<p>
env.setInitialContextFactory("weblogic.jndi.WLInitialContextFactory");
<p>
env.setSecurityPrincipal(username);
<p>
env.setSecurityCredentials(password);
<p>
return new InitialContext(env.getInitialContext().getEnvironment());
<p>
<p>
public static void main(String [] args)
<p>
MyService ms = new MyService();
<p>
System.out.println(ms.testMethod2());
<p>
<p>
<p>test
-
Using Datasources with Weblogic 7.2
Hi everyone,
I am using Weblogic 7.2 with Db2 8.1 fp3(Type 4 Drivers). I am wanting
to set up a Datasource that would allow my application to connect to
DB2 using the JNDI lookup for that data-source.
My question is: what additions/changes I need to make to config.xml in
order to set this up.Looking at the Websphere Admin Doc, it seems to
me that I need to atleast add 2 elements to my domain in config.xml:
1. JDBCConnectionPool
2. JDBCDataSource(and link it to the above pool)
I have previously set-up datasources on WAS 5.0. What is confusing me
w.r.t Weblogic is that there seems to be no way to specify the
implementing class for the DataSource. e.g. WAS5.0 allows you to
specify the implementationClassName of the
datasource(com.ibm.db2.jcc.DB2ConnectionPoolDataSource in my case) while
defining the DataSource.JDBCConnectionPool element in Weblogic does
have an attribute called "DriverName" but per the documentation it
should be set to an implementor of java.sql.Driver interface: there
seems to be no way to set an implementor of javax.sql.DataSource
anywhere.
Could anyone please shed some light on how to set this up?
Thanks much in advance,
SachinMitesh,
Many thanks for the reply. If you don't mind, I have a couple of follow-up questions
for you.
1> Does this mechanism work with Type 4 Pure Java Drivers?
e.g. if I specified the connection pool as
<JDBCConnectionPool DriverName="com.ibm.db2.jcc.DB2ConnectionPoolDataSource" Name="IBM-db2"
Password="MYPASSWORD" Properties="user=USERNAME;DatabaseName=DATABASE" Targets="MYSERVER"
TestTableName="SQL SELECT COUNT(*) FROM SYSIBM.SYSTABLES" URL="jdbc:db2:DATABASE"/>
==> I changed the DriverName to "com.ibm.db2.jcc.DB2ConnectionPoolDataSource"
which
is what I believe is the Type-4 version
2> Setting the DriverName to a javax.sql.DataSource extension seems to suggest
that the documentation in the "BEA Server Configuration Reference" guide is incorrect:
-- For the DriverName attribute of the Connection Pool, the guide says that "DriverName
must be the name of a class that implements the java.sql.Driver interface"
Thanks again
Sachin
Mitesh Patel <[email protected]> wrote:
<JDBCConnectionPool DriverName="COM.IBM.db2.jdbc.DB2XADataSource"
Name="IBM-db2-xa"
Password="MYPASSWORD"
Properties="user=USERNAME;DatabaseName=DATABASE"
Targets="MYSERVER"
TestTableName="SQL SELECT COUNT(*) FROM SYSIBM.SYSTABLES"
URL="jdbc:db2:DATABASE"/>
<JDBCConnectionPool DriverName="COM.IBM.db2.jdbc.app.DB2Driver"
Name="IBM-db2"
Password="MYPASSWORD"
Properties="user=USERNAME;DatabaseName=DATABASE"
Targets="MYSERVER"
TestTableName="SQL SELECT COUNT(*) FROM SYSIBM.SYSTABLES"
URL="jdbc:db2:DATABASE"/>
Then setup your datasource using one of this connection pools in your
config.xml. Also, make sure your driver zip files are in the classpath.
Thanks,
Mitesh
Sachin Arora wrote:
Hi everyone,
I am using Weblogic 7.2 with Db2 8.1 fp3(Type 4 Drivers). I am wanting
to set up a Datasource that would allow my application to connect to
DB2 using the JNDI lookup for that data-source.
My question is: what additions/changes I need to make to config.xmlin
order to set this up.Looking at the Websphere Admin Doc, it seems to
me that I need to atleast add 2 elements to my domain in config.xml:
1. JDBCConnectionPool
2. JDBCDataSource(and link it to the above pool)
I have previously set-up datasources on WAS 5.0. What is confusingme
w.r.t Weblogic is that there seems to be no way to specify the
implementing class for the DataSource. e.g. WAS5.0 allows you to
specify the implementationClassName of the
datasource(com.ibm.db2.jcc.DB2ConnectionPoolDataSource in my case)while
defining the DataSource.JDBCConnectionPool element in Weblogic does
have an attribute called "DriverName" but per the documentation it
should be set to an implementor of java.sql.Driver interface: there
seems to be no way to set an implementor of javax.sql.DataSource
anywhere.
Could anyone please shed some light on how to set this up?
Thanks much in advance,
Sachin -
Is it possible to use ArrayList with TopLink?
Hi all,
I got used to using Arraylist as the class to perform relationships between classes. Now i'm starting to work with jDeveloper and TopLink.
All my mappings were done automatically using Collection. I can see that in "Container Policy" i can choose between Collection and Map. Is it impossible to work with other type of List/Collection/Set/whatever?
If it is possible? How?
Thanks a lot
EduardoHi Eduardo,
To do this you need to specify the "Collection Class" on the "Container Policy" for the mapping. In this case you will specify that the collection class is java.util.ArrayList. In JDeveloper this can be found on the "Collection Options" panel for the mapping.
TopLink specific questions can also be posted on the TopLink forum:
TopLink/JPA
-Blaise -
How to use datasources to connect to database ?
I have the following Problem
I have two identical databases, one is the development database, the other one the production database.
Now I need to find a way, how I can deploy an bc4j-application in local mode that way, that if the application is deployed to server 1 it connects to database 1 and if deployed to server 2 it connects to database 2.
JDBC connection strings do not work as the connection is deployed with the application. So the application always connects to the same database.
I thought datasources might be the solution. So I tried to define a datasource MyDS in the data-sources.xml file and specified it in the Configuration Wizard as the connection to use.
But unfortunately this does not work and i do not know why:
If I try to connect using the tester and using this datasource I get the following exception:
Level #3: javax.naming.noInitialContextException
Can anyone help me, what this means? How can I get around this using the BC4J Framework? Is there any "HowTo" Document which describes using datasources with BC4J?Frank,
I've sorted this stuff out to some extent. Have a look at this thread:
re:? How: multiple myAppWar.ear to use OC4J's data-sources.xml pooling?
If this isn't all you need, then search on data-source.xml
and read other threads also I may have posted helps on
other threads so if you search on data-source.xml and my handle (curt504) it brings up all the threads that I posted to.
Not to say I've solved all your problems, but I solved mine anyway. :)
Good luck,
curt -
EJB 2.1 Timer bean using CMT (WAS 6.0) with Toplink 10.1.3
I have a timer bean that is calling a toplink transaction. The timer bean uses CMT with a "RequiresNew" transaction attribute. The ejbTimeout() method of the bean calls a toplink transaction - this transaction includes code to do uow.commit().
I am using the external transaction controller. Here is the relevant portion of the sessions.xml file:
<login>
<datasource>jdbc/XvsOMDataSource</datasource>
<platform-class>oracle.toplink.oraclespecific.Oracle9Platform</platform-class>
<uses-external-connection-pool>true</uses-external-connection-pool>
<uses-external-transaction-controller>true</uses-external-transaction-controller>
</login>
<external-transaction-controller-class>com.ford.it.persistence.impl.toplink.JTSExternalTransactionControllerExtended_WAS6</external-transaction-controller-class>
When the uow.commit is being executed, Toplink tries to get the UserTransaction but since the code has been invoked by a CMT EJB - access to the UserTransaction is not allowed and my transaction fails as follows:
[7/19/06 7:46:30:539 EDT] 00000048 TransactionHe E com.ford.it.persistence.impl.toplink.TransactionHelper getUserTransaction Cannot obtain UserTransaction from JNDI. <javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".>javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".
If I don't use the external transaction controller, the transaction again fails on uow.commit() - saying that Connection.commit() cannot be explicitly called, since it is part of a global transaction.
All I want, is for Toplink to just fire the SQL during uow.commit() (without issuing a Connection.commit()) - the CMT timer bean will take care of the Connection.commit.
Any thoughts on how to resolve this issue?
Prabodh.The problem has been resolved. It was a usage-related issue. Thank you all.
-
Problem getting XA Datasources to work with Toplink inside Weblogic
Hello,
I am using POJOs inside weblogic 7.1, and I am having some difficulties. Of picked up a jdbc driver called JSQLConnect and it sets up fine from the Weblogic console. This is the only 3rd party XA driver that I have successfully got working inside weblogic.
I've set up the Weblogic datasource in toplink per the documentation/examples I found. I've included a stack trace of where things blow up. From your source code, it looks like the AbstractSynchronizationListener thinks that the unit of work is not active. Thanks in advance for any assistance. Mike
UnitOfWork(2416860)--release unit of work
UnitOfWork(2416860)--JTS#beforeCompletion()
UnitOfWork(2416860)--JTS#afterCompletion()
UnitOfWork(2416860)--release unit of work
ClientSession(2454268)--client released
<May 14, 2003 3:39:10 PM MDT> <Error> <EJB> <010026> <Exception during commit of transacti
on 12:591b650d7f28edb9: weblogic.transaction.internal.AppSetRollbackOnlyException
at weblogic.transaction.internal.TransactionImpl.setRollbackOnly(TransactionImpl.j
ava:467)
at oracle.toplink.jts.JTSSynchronizationListener.rollbackGlobalTransaction(Unknown
Source)
at oracle.toplink.jts.AbstractSynchronizationListener.beforeCompletion(Unknown Sou
rce)
at weblogic.transaction.internal.ServerSCInfo.callBeforeCompletions(ServerSCInfo.j
ava:540)
at weblogic.transaction.internal.ServerSCInfo.startPrePrepareAndChain(ServerSCInfo
.java:92)
at weblogic.transaction.internal.ServerTransactionImpl.localPrePrepareAndChain(Ser
verTransactionImpl.java:1044)
at weblogic.transaction.internal.ServerTransactionImpl.globalPrePrepare(ServerTran
sactionImpl.java:1581)
at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransa
ctionImpl.java:237)
at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImp
l.java:208)
at weblogic.ejb20.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:278)
at com.icat.server.infrastructure.legacyint.LegacyIntegrationServiceImpl_eayqrf_EO
Impl.transferLegacyData(LegacyIntegrationServiceImpl_eayqrf_EOImpl.java:56)
at com.icat.common.infrastructure.legacyint.LegacyIntegrationTask.execute(LegacyIn
tegrationTask.java:165)
at com.icat.common.infrastructure.scheduling.ScheduledTask.executeMyTask(Scheduled
Task.java:142)
at com.icat.common.infrastructure.scheduling.ScheduledTask.run(ScheduledTask.java:
297)
at java.lang.Thread.run(Thread.java:479)Hi Michael,
I will have to set things up again to try it. I've been in the middle of doing other development and haven't gotten back to the XA Driver attempts again. Can you send me an email where I can fire a note to you directly once I try this again? I will probably need to send you code, etc. Mine is [email protected]
As for your questions, let me address them below:
How are you using XA (e.g. are you talking to two different databases)? Are you using TopLink any differently (e.g. using SessionBroker)? Is your transaction being propagated to multiple servers? What exactly has changed, or have you simply started using a different driver/data source? (Sorry for all the questions, just want to try to hone in on what components we are looking at).
BTW, do transactions ever get started by the client and span multiple server requests?
1) Yep, I am reading from one database, and writing to the other. So its not a two phase commit right now, but we will have one in the future.
2) I'm not using your session broker. We have a framework, where we can get a client session from a named server session. This works pretty well for us. Right now, we are using the same framework to access two databases. I'm just not setting external tx control, session synchornization,etc
3) I can use the third party jdbc driver in a non-XA transaction. So it doesn't seem to be a property of the JDBC driver alone. It seems to be when I attempt to set things up in XA mode.
4) Transactions are controlled at the Session Bean level. They only last for one bean request.
If you have any cycles, I was wondering if you could try getting the XA transaction to work in your environment? I was using Net-Direct's driver, along with Weblogic 7.1 sp1, and Toplink 9.0.3.3 (Build 430). An example of how you got things to work may point out what is different about my useage.... -
Using Transformations with Delta enabled Datasources
Hi,
I have a delta enables datasource which uses incremental update to my infoCube.
In order to populate some fields in the cube I used a transformation routine for a couple of these fields to do some lookups from some tables.
The problem that I am encountering is that when the delta update runs its only updates the directly assigned fields it does not also update the routine delivered fields.
Is there a way to get this to work or is it impossible?
ThanksHI,
The routines work fine for full load as the data is replaced with new data each time.
What I need to happen is I am using a SAP standard content datasource with delta enabled on the datasource and when loading from datasource to Cube all the 0 fields are updating correctly but my Z fields which i update with routines do not seem to be replaced.
Please advise of anyway to get this to work
Thanks -
Populating BW datasource with data using Webservice without PI (=XI)
Hi all,
I have got BW datasource and I want to be able to use external Webservice's method to populate my data source with data.
I have created client proxy in BW ( se80 --> Enterprise Services --> Client Proxy ) for my wsdl and logical port in SOAMANGER for my proxy.
I have also created datasource.
Now I need to use one of the methods of the Webservice (proxy ) to populate my datasource with data. This is the bit I am struggling with.
I had a look here on SND but I could not find anything useful. Can you please advice ? Any examples ?
Please let me know whatever you know and maybe helpful.
Feel free to ask questions if I am not detailed enough in my description of the problem.
Regards
Agnieszka Domanska
Edited by: Agnieszka Domanska on Nov 10, 2010 5:41 PMI have now been able to call a method of the Webservice by writing the simple code:
DATA:
Reference variables for proxy and exception class
lo_clientproxy TYPE REF TO ZCO_ICAMPAIGN_MASTER_SERVICE,
lo_sys_exception TYPE REF TO cx_ai_system_fault,
Structures to set and get message content
ls_request TYPE ZICAMPAIGN_MASTER_SERVICE_GE25,
ls_response TYPE ZICAMPAIGN_MASTER_SERVICE_GE24.
Populate the Request of the SOAP Object
ls_request-CAMPAIGN_ID = '74500'.
****Create the Proxy and Call it.
CREATE OBJECT lo_clientproxy.
TRY.
CALL METHOD lo_clientproxy->GET_EMAIL_CAMPAIGN_SUMMARY
EXPORTING
input = ls_request
IMPORTING
output = ls_response.
CATCH cx_ai_system_fault INTO lo_sys_exception.
Error handling
ENDTRY.
COMMIT WORK. -
Bad performance when using complex database view with Toplink
Hi
Problem description
1. I have a complex query that collects the data from many DB tables. For this reason I create a database view based on this select. Using EJB 3.0 with Toplink I
mapped this view to a java object the same way I map database tables. The method I use to get the results is:
snippet code...
public List<VwKartela> VwKartela(Integer pperid) {
List<VwKartela> results = null;
Session session = getSessionFactory().acquireSession();
ExpressionBuilder bankfile = new ExpressionBuilder();
Expression exp1 = bankfile.get("perid").equal(pperid);
ReadAllQuery query = new ReadAllQuery();
query.setReferenceClass(VwKartela.class);
query.setSelectionCriteria(exp1);
results =(List<VwKartela>)session.executeQuery(query);
When running the select on the view prom SQL Plus I haven’t any performance problem.
2.Question: How can I improve the performance? I referenced to Toplink docs but I didn't improve the it.
Have anyone any experience is such cases?
Thank you
ThanosHi
After my last tests I conclude at the followings:
The query returns 1-30 records
Test 1: Using Form Builder
- Execution time 7-8 seconds
Test 2: Using Jdeveloper/Toplink/EJB 3.0/ADF and Oracle AS 10.1.3.0
- Execution time 25-27 seconds
Test 3: Using JDBC/ADF and Oracle AS 10.1.3.0
- Execution time 17-18 seconds
When I use:
session.setLogLevel(SessionLog.FINE) and
session.setProfiler(new PerformanceProfiler())
I don’t see any improvement in the execution time of the query.
Thank you
Thanos -
Has any one has experience using WLE transaction context together with TOPLINK Java
version of "commit and resume" context?Has any one has experience using WLE transaction context together with TOPLINK Java
version of "commit and resume" context? -
Urg Problem with using DataSources in Tomcat
I am trying to use DataSource in Tomcat4.0
I have a simple jsp file as shown below:=
<html>
<head>
<title>DB Test using DataSource</title>
</head>
<body>
<%
foo.DBTest dbt = new foo.DBTest();
dbt.init();
%>
<h2>Results</h2>
Foo <%= dbt.getFoo() %>
Bar <%= dbt.getBar() %>
</body>
</html>
and a Servlet by the name of DBTest as shown below:-
package foo;
import javax.naming.*;
import javax.sql.*;
import java.sql.*;
public class DBTest
String foo = "Not Connected";
int bar = -1;
public void init()
try
System.out.println("Inside INIT of DBTest");
Context ctx = new InitialContext();
Context envCtx = (Context)ctx.lookup("java:comp/env");
if(ctx == null )
throw new Exception("Boom - No Context");
//DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/TestDB");
DataSource ds = (DataSource)envCtx.lookup("jdbc/TestDB");
if (ds != null)
Connection conn = ds.getConnection();
if(conn != null)
foo = "Got Connection "+conn.toString();
Statement stmt = conn.createStatement();
ResultSet rst = stmt.executeQuery("select id, foo, bar from testdata");
if(rst.next())
foo=rst.getString(2);
bar=rst.getInt(3);
conn.close();
}catch(Exception e)
e.printStackTrace();
}//end of init
public String getFoo() { return foo; }
public int getBar() { return bar;}
}//end of class
I modified my server.xml file to include this:=
<!-- Tomcat My DataSource Testing Context -->
<Context path="/DBTest" docBase="C:\Program Files\Apache Tomcat 4.0\webapps\DBTest"
debug="5" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_DBTest_log." suffix=".txt"
timestamp="true"/>
<Resource name="jdbc/TestDB"
auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/TestDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>5</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<parameter>
<name>username</name>
<value>system</value>
</parameter>
<parameter>
<name>password</name>
<value>manager</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.OracleDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:oracle:thin:@localhost:1521:Test2</value>
</parameter>
</ResourceParams>
</Context>
<!-- Tomcat My DataSource Testing Context -->
and my web.xml file is as shown below:=
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<description>Oracle DataSource Test App</description>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/TestDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
Now when i start Tomcat and try to access the jsp page i get this error in Tomcat Console:=
Inside INIT of DBTest
javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.NamingContext.lookup(NamingContext.java:837)
at org.apache.naming.NamingContext.lookup(NamingContext.java:181)
at org.apache.naming.NamingContext.lookup(NamingContext.java:822)
at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
at foo.DBTest.init(DBTest.java:25)
at org.apache.jsp.test$jsp._jspService(test$jsp.java:60)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspSer
vlet.java:202)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
82)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:201)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:
2344)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:164)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche
rValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
462)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:163)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcesso
r.java:1011)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.ja
va:1106)
at java.lang.Thread.run(Unknown Source)
Why is this happening .
I am making sure the resource name in server.xml and web.xml are the same
Any Help highly appreciated
Thanks
RajHi rajess_kr,
Looks to me like you're pretty close.
I'm assuming that you've got the JDBC driver JAR in TOMCAT_HOME/common/lib. The JAR containing your data source factory class org.apache.commons.dbcp.BasicDataSourceFactory should be in that directory, too. Since you're using Oracle, I'd also suggest that you repackage classes12.zip as a JAR file if it's not already a JAR.
I think the JNDI lookup string should be "java:comp/env/jdbc/TestDB".
I've got a working example on my desktop at work, but I don't seem to have one here at home. I'll give it a look on Monday and see if I can provide more details. It looks to me like you're not very far off. - MOD
Maybe you are looking for
-
Download the ALV Report output into excel sheet or notepad
Hi, how to downlaod the alv report out into excel sheet or notepad in a proper manner. program contain large number records.... Thanks in advance!!!! Regards, kranthi.
-
Why we will go for Queue delta instead of Unserialized and Direct delta ?
Hi Experts, Why we will go for Queue delta instead of Unserialized and Direct delta ? specify any reasons for that ? What happens internally when we use Queue delta , Direct delta ? I will allocate points to those who help me in detail. My advance th
-
I am trying to build a page to upload pdf files to my website. It is an intranet site for real estate agents. I tried making a form with a file field and then applied the Developer toolkit file upload behavior. When I try to view the page I get this
-
I am attempting to create a Blu-Ray ISO file of a Premiere Elements 12 project. PRE12 is installed on a Dell XPS 420 with Windows Vista SP2. I have completed the project and installed Phantom Burner 2.0. I have created the Phantom Burner file by ri
-
E-Recruitment External Candidate Page in Portal
Hello All, we have E-Recruitment 6.0(Stand alone installation) and EP 7.0. Have configured Anonymous logon in portal and created iViews for the External page(ABAP webdynpro for application hrrcf_a_startpage_ext_cand), since its a ABAP Webdynpro iView