How is Connection Pooler Found
In Tomcat (say) one defines a resource like
<Resource name="jdbc/myjdbc" type="javax.sql.DataSource"/>...
(Note that DataSource is an interface, not a class.)
In the code we then just say
envCtx=InitialContext().lookup("java:comp/env");
DataSource ds = envCtx.lookup("jdbc/myjdbc");
But how on earth does JNDI/Tomcat know which factory to use create a DataSource? How does it know to use DBCP for this connection, and not some other pool? How could it without having weird hooks into JINDI?
Anthony
OK so there is an additional factory parameter that presumably has a default value of dbcp.
<Resource name="jdbc/testdbfPool1" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/testDBFPool1">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.hxtt.sql.dbf.DBFDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:dbf:///d:/dbffiles</value>
</parameter>
Thanks for the reply. I was surprised not to see something on the jdbc resource definition, forgot about defaults.
Anthony
Similar Messages
-
How database connection pooling works in a application
Hi Guys,
I am new to Java and looking into best way of doing J2ee database conectivity. I am using Eclipse galileo3.5 J2EE with Mysql database and Tomcate 6.0.
I am developing an email application where I need to implement MVC model for my webapplication, using jsp for presentation, servlet for control and java beans for model.
I came across two tutorial for database connection pooling as given below.
Eclipse Corner Article: Creating Database Web Applications with Eclipse - In this tutorial connection pooling is configure in Tomcate 6.0
It says Copy and paste the following into your context.xml file (you may have to click on the Source tab at the bottom of the editor to be able to paste). This defines a DataSource with the name "jdbc/SampleDB". Our application will retrieve database connections from the pool using this name.
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name="jdbc/SampleDB" auth="Container"
type="javax.sql.DataSource"
username="app" password="app"
driverClassName="org.apache.derby.jdbc.ClientDrive r"
url="jdbc:derby://localhost:1527/sample"
maxActive="8" />
</Context>
Where as in second tutorial - http://www.roseindia.net/answers/viewanswers/2838.html
It uses java bean for connection pooling and then use straight way in JSP and no Servlet used.
conpool.jsp
<%@page import="java.sql.Connection"%>
<jsp:useBean id="pl" class="com.CoreJava.ConnectionPooling"/>
<% Connection con = pl.getConnection(); %>
//do something using con
connectionPooling.java
import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolD ataSource;
public class ConnectionPooling
static Connection con=null;
public static Connection getConnection()
try
MysqlConnectionPoolDataSource po=new MysqlConnectionPoolDataSource();
po.setServerName("localhost");
po.setPortNumber(3306);
po.setDatabaseName("mydatabase"); //changeur database name
po.setUser("root");//ur username
po.setPassword("");//ur password
con = po.getConnection();
catch(Exception e)
System.out.println("Exception Connection :"+e);
return con;
Please some one explain which is the best way of doing connection pooling to the database by using MVC pattern
Please if some one advise me how to use MVC architecture for simple email application and database connectivty.
Thanks>
>
Where as in second tutorial - http://www.roseindia.net/answers/viewanswers/2838.html
Never EVER use roseindia. It is terrible shit.
[http://balusc.blogspot.com/2008/06/what-is-it-with-roseindia.html]
The correct answer is what you found in the eclipse article. And you can read the Tomcat docs for more.
As per usual the code you have posted from Roseindia is a big pile of rubbish that was written by a complete idiot. I mean the person who wrote it apparently doesn't know much Java at all. Let alone JDBC. Or Connection pools. Or J2EE. It's not the worst I've seen from them but it's pretty bad. -
How is connection pooling done in ias ?
is it the "DataSource Registration' ->'DataSource Pool' ->'MaxPoolSize' or is it 'Data Access Driver'-> 'Cache'-> 'Maximum Connections'
or is it somewhere else ?The connection pool settings for a particular datasource should be done in Datasource Pool-> MaxPoolSize.
The Driver-> Maximum Connections is the maximum no. of connections to the particular database.
Note the difference between these two, two different datasources could connect to a database using the same database driver.
Hope this helps.
Thanks,
Rakesh. -
How to use connection pools in production environment
Hai
We are using Statless Session beans which will call bean managed entity beans
as a developer we completed the first phase of our project successful but when
comming to the production environment they(Higher authoritites of the company)
are asking abt the connection pools. Suppose if my wlserver5.1 has 100 hits per
a second how many connection pools i need to put in the production envirornment
and also is it the right way to increase the connectionpools depends upon the
clients hits????. Can anybody help me regarding this It is very urgent for us.
Cheers Kiran NallamHi Aravind,
It can be used only for calculation kinda "minimum size".
Nothing can prevent a developer from writing something
like this:
Connection con1 = ds.getConnection();
Connection con2 = ds.getConnection();
Connection con3 = ds.getConnection();
Regards,
Slava Imeshev
"Aravind Krishnasamy" <[email protected]> wrote in message news:3bfa85f6
You can fix the size of the weblogic connection pool depending on yourexecute
thread count value. For example the default value of execute thread countvalue
is 15. So at a given point of time you cannot use more then 15 databaseconnection.
Database connection pool size should be equal to or less then the size ofexecute
thread count
"Slava Imeshev" <[email protected]> wrote:
Hi Kiran,
It's hard to provide exact dependence between number of hits
and actual number of consumed connections because it's a highly
variable distributed environment. But the general approach is
simple - before rolling out your application, make sure you
tested it under simulated peak load. Your connection pool should
have enough connections to serve peak load. Without such a testing
you will never know whether your app scales or not.
Regards,
Slava Imeshev
"Kiran" <[email protected]> wrote in message
news:3bf9d676$[email protected]..
Hai
We are using Statless Session beans which will call bean managed entitybeans
as a developer we completed the first phase of our project successfulbut
when
comming to the production environment they(Higher authoritites of thecompany)
are asking abt the connection pools. Suppose if my wlserver5.1 has100
hits per
a second how many connection pools i need to put in the productionenvirornment
and also is it the right way to increase the connectionpools dependsupon
the
clients hits????. Can anybody help me regarding this It is very urgentfor
us.
Cheers Kiran Nallam -
ABAP MDM Connection Pool concept? Slow Performance in call
Hi,
I'm playing around with the MDM ABAP API, and I found the performance a bit disappointing.
I followed the guide "How To identify master data records using SAP MDM 5.5 ABAP API's" and wrote a test program.
The program makes a connection, triggers an MDM query, and disconnects.
CREATE OBJECT api
EXPORTING
iv_log_object_name = logical_object_name.
api->mo_accessor->connect( language ).
* Query parameters
ls_query-parameter_code = 'Material_Number'.
ls_query-operator = 'CS'.
ls_query-dimension_type = 1.
ls_query-constraint_type = 8.
ls_value = '70'.
GET REFERENCE OF ls_value INTO ls_query-value_low.
APPEND ls_query TO lt_query.
CLEAR ls_query.
* Search
CALL METHOD api->mo_core_service->query
EXPORTING
iv_object_type_code = 'Products'
it_query = lt_query
iv_hits_max = 10
IMPORTING
et_result_set = lt_result_set.
Connection is really fast (a split second)
First time triggered 'query' method took about 30-50 seconds.
Second time triggering 'query' method took a split second.
Further to my investigation, I found out the most expensive code lies in
CL_MDM_PROVIDER_SP04_PL03->IF_MDM_CORE_SERVICES~QUERY
*--- load field meta data ---*
IF mt_mdm_field_meta_data IS INITIAL
OR mt_field_meta_data IS INITIAL.
CALL METHOD me->_load_field_information.
ENDIF.
Within this method loadfield_information, it rips all the table and structure information
from MDM, and ALL language texts and so on.
It has many loops, and within the loops querying MDM for more information.
Is there anyway to speed this up?
Why aren't these data cached? (They don't change so often in a production environment)
I also found a shared memory class CL_MDM_METADATA_ACCESS but it is not used anywhere.
No shared memory area relevant is delivered by SAP as well.
Any ideas?
Cheers,
Michael.Hi Michael,
you're welcome.
I'm not sure how the Connection Pooling to MDM is really done by the ABAP APIs as I'm unfortunately not an API developer but just use the API for my programms.
What I learned during this process is that the repository meta data (meaning table descriptions, and so on) have to be loaded at least once for each connection. This makes sense because a repository can always be changed manually by any user. And I don't think that it would be faster to hold the meta data persistent in the ABAP layer because then you would need to compare the ABAP available meta information with the current meta information of the repository. This could take even longer.
I've solved this "issue" in a way that I really rely on the connection because a single connection is very stable. So I call the "CONNECT" only once in the very beginning, run through my coding and the very last step is the "DISCONNECT". As long as a connection is available, the meta data is cached in the API layer (at least this is the case for SP05).
BR Michael -
Hi there,
I was previously using the jferner/node-oracle module with the "generic-pool" (https://github.com/coopernurse/node-pool) module for connection pooling.
I'm trying out a setup with connection pooling with node-oracledb and have a few questions:
* If an execute call fails with a connection i've retrieved from the pool, and I want to destroy that connection and remove it from the pool, how do I do that? Is it done implicitly for me?
* Is there any way to validate a connection before it's used? Or again, is this done implicitly? Is there a way to toggle it on and off for perf tuning?
* Is there any way to tune how frequently Oracle checks for idle connections? (In generic-pool this was called reapIntervalMillis)
* Is there any way to turn on any logging of how the connection pool behaves for development debugging? I just want to make sure my setup is behaving as I think it should be.
I'm making some good headway on getting the module working and it wasn't too difficult a conversion from node-oracle, either, that's good!
-MattYou should release() bad connections to the pool so the pool can replace them.
Validating connections is generally not worth it: between validation & use there could be a failure, so your executions need to handle errors anyway. Why reduce scalability and performance by doing an extra "round trip" for validation? Also you can use FAN which can proactively clean up idle sessions in the session pool that are affected by the DB instance disappearing (due to network glitches etc).
The client-side pool is handled by Oracle session pooling, so the algorithms are opaque. -
Cannot create a sybase connection pool
I am trying to migrate from Orion app server to Sun One appserver. Here is how I define the connection pool for orion
<data-source class="com.evermind.sql.DriverManagerDataSource"
name="TestPool"
location="jdbc/rumbaDataSource"
xa-location="jdbc/xa/rumbaPool"
ejb-location="jdbc/rumbaPool"
connection-driver="com.sybase.jdbc2.jdbc.SybXADataSource"
connection-retry-interval="60"
username="test"
password="test"
url="jdbc:sybase:Tds:3.23.24.25:20000/abc?HOSTNAME=rumba"
inactivity-timeout="300"
min-connections="6"
max-connections="75"
/>
This is how my connection pool appears in Sun ONE
<jdbc-connection-pool steady-pool-size="8" max-pool-size="32" max-wait-time-in-millis="60000" pool-resize-quantity="2" idle-timeout-in-seconds="300" is-isolation-level-guaranteed="false" is-connection-validation-required="false" connection-validation-method="auto-commit" fail-all-connections="false" datasource-classname="com.sybase.jdbc2.jdbc.SybXADataSource" name="TestPool">
<property value="3.23.24.25" name="serverName"/>
<property value="20000" name="portNumber"/>
<property value="jdbc:sybase:Tds:" name="networkProtocol"/>
<property value="test" name="user"/>
<property value="test" name="password"/>
<property value="abc" name="databaseName"/>
</jdbc-connection-pool>
But, I am unable to make a connection using this connection poolHere is the exception
SEVERE: RAR5041:Cannot get jdbc connection
com.sun.enterprise.repository.J2EEResourceException
java.lang.NoSuchMethodException: seturl
at com.sun.enterprise.repository.JdbcConnectionPool.createDataSource(Jdb
cConnectionPool.java:243)
at com.sun.enterprise.resource.JdbcUrlAllocator.createResource(JdbcUrlAl
locator.java:80)
at com.sun.enterprise.resource.IASNonSharedResourcePool.createSteadyReso
urces(IASNonSharedResourcePool.java:856)
at com.sun.enterprise.resource.IASNonSharedResourcePool.initPool(IASNonS
haredResourcePool.java:416)
at com.sun.enterprise.resource.IASNonSharedResourcePool.internalGetResou
rce(IASNonSharedResourcePool.java:625)
at com.sun.enterprise.resource.IASNonSharedResourcePool.getResource(IASN
onSharedResourcePool.java:520)
at com.sun.enterprise.resource.PoolManagerImpl.getResourceFromPool(PoolM
anagerImpl.java:263)
at com.sun.enterprise.resource.JdbcXAConnection.<init>(JdbcXAConnection.
java:74)
at com.sun.enterprise.resource.Jdbc10XaAllocator.createResource(Jdbc10Xa
Allocator.java:94)
at com.sun.enterprise.resource.IASNonSharedResourcePool.createSteadyReso
urces(IASNonSharedResourcePool.java:856)
at com.sun.enterprise.resource.IASNonSharedResourcePool.initPool(IASNonS
haredResourcePool.java:416)
at com.sun.enterprise.resource.IASNonSharedResourcePool.internalGetResou
rce(IASNonSharedResourcePool.java:625)
at com.sun.enterprise.resource.IASNonSharedResourcePool.getResource(IASN
onSharedResourcePool.java:520)
at com.sun.enterprise.resource.PoolManagerImpl.getResourceFromPool(PoolM
anagerImpl.java:263)
at com.sun.enterprise.resource.PoolManagerImpl.getResource(PoolManagerIm
pl.java:170)
at com.sun.enterprise.resource.JdbcDataSource.internalGetConnection(Jdbc
DataSource.java:241)
at com.sun.enterprise.resource.JdbcDataSource.getConnection(JdbcDataSour
ce.java:124)
at samples.jdbc.simple.servlet.GreeterDBLogDisplayServlet.doGet(Unknown
Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.StandardWrapperValve.invokeServletService(St
andardWrapperValve.java:720)
at org.apache.catalina.core.StandardWrapperValve.access$000(StandardWrap
perValve.java:118)
at org.apache.catalina.core.StandardWrapperValve$1.run(StandardWrapperVa
lve.java:278)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:274)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:505)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:212)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:203)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:505)
at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProce
ssor.java:157)
at com.iplanet.ias.web.WebContainer.service(WebContainer.java:598)
INFO: CORE3282: stdout: - Could not interact with the database
INFO: CORE3282: stdout: - Exception: java.sql.SQLException: com.sun.enterprise.r
epository.J2EEResourceException
WARNING: CORE3283: stderr: at com.sun.enterprise.repository.JdbcConnectionP
ool.createDataSource(JdbcConnectionPool.java:238)
WARNING: CORE3283: stderr: at com.sun.enterprise.resource.JdbcUrlAllocator.
createResource(JdbcUrlAllocator.java:80)
WARNING: CORE3283: stderr: at com.sun.enterprise.resource.IASNonSharedResou
rcePool.createSteadyResources(IASNonSharedResourcePool.java:856)
INFO: CORE3282: stdout: java.lang.NoSuchMethodException: seturl
INFO: CORE3282: stdout: Closing statement...
WARNING: CORE3283: stderr: at com.sun.enterprise.resource.IASNonSharedResou
rcePool.initPool(IASNonSharedResourcePool.java:416)
WARNING: CORE3283: stderr: at com.sun.enterprise.resource.IASNonSharedResou
rcePool.internalGetResource(IASNonSharedResourcePool.java:625)
INFO: CORE3282: stdout: - Could not close the statement and connection
INFO: CORE3282: stdout: GreeterDBLogDisplayServlet is all done
WARNING: CORE3283: stderr: at com.sun.enterprise.resource.IASNonSharedResou
rcePool.getResource(IASNonSharedResourcePool.java:520)
WARNING: CORE3283: stderr: at com.sun.enterprise.resource.PoolManagerImpl.g
etResourceFromPool(PoolManagerImpl.java:263)
WARNING: CORE3283: stderr: at com.sun.enterprise.resource.JdbcXAConnection.
<init>(JdbcXAConnection.java:74)
WARNING: CORE3283: stderr: at com.sun.enterprise.resource.Jdbc10XaAllocator
.createResource(Jdbc10XaAllocator.java:94)
WARNING: CORE3283: stderr: at com.sun.enterprise.resource.IASNonSharedResou
rcePool.createSteadyResources(IASNonSharedResourcePool.java:856)
WARNING: CORE3283: stderr: at com.sun.enterprise.resource.IASNonSharedResou
rcePool.initPool(IASNonSharedResourcePool.java:416)
WARNING: CORE3283: stderr: at com.sun.enterprise.resource.IASNonSharedResou
rcePool.internalGetResource(IASNonSharedResourcePool.java:625)
WARNING: CORE3283: stderr: at com.sun.enterprise.resource.IASNonSharedResou
rcePool.getResource(IASNonSharedResourcePool.java:520)
WARNING: CORE3283: stderr: at com.sun.enterprise.resource.PoolManagerImpl.g
etResourceFromPool(PoolManagerImpl.java:263)
WARNING: CORE3283: stderr: at com.sun.enterprise.resource.PoolManagerImpl.g
etResource(PoolManagerImpl.java:170)
WARNING: CORE3283: stderr: at com.sun.enterprise.resource.JdbcDataSource.in
ternalGetConnection(JdbcDataSource.java:241)
WARNING: CORE3283: stderr: at com.sun.enterprise.resource.JdbcDataSource.ge
tConnection(JdbcDataSource.java:124)
WARNING: CORE3283: stderr: at samples.jdbc.simple.servlet.GreeterDBLogDispl
ayServlet.doGet(Unknown Source)
WARNING: CORE3283: stderr: at javax.servlet.http.HttpServlet.service(HttpSe
rvlet.java:740)
WARNING: CORE3283: stderr: at javax.servlet.http.HttpServlet.service(HttpSe
rvlet.java:853)
WARNING: CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve
.invokeServletService(StandardWrapperValve.java:720)
WARNING: CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve
.access$000(StandardWrapperValve.java:118)
WARNING: CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve
$1.run(StandardWrapperValve.java:278)
WARNING: CORE3283: stderr: at java.security.AccessController.doPrivileged(N
ative Method)
WARNING: CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve
.invoke(StandardWrapperValve.java:274)
WARNING: CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.inv
oke(StandardPipeline.java:505)
WARNING: CORE3283: stderr: at org.apache.catalina.core.StandardContextValve
.invoke(StandardContextValve.java:212)
WARNING: CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.inv
oke(StandardPipeline.java:505)
WARNING: CORE3283: stderr: at org.apache.catalina.core.StandardHostValve.in
voke(StandardHostValve.java:203)
WARNING: CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.inv
oke(StandardPipeline.java:505)
WARNING: CORE3283: stderr: at com.iplanet.ias.web.connector.nsapi.NSAPIProc
essor.process(NSAPIProcessor.java:157)
WARNING: CORE3283: stderr: at com.iplanet.ias.web.WebContainer.service(WebC
ontainer.java:598) -
Calculation of no of connection pools required...
hi,
1. How many connections can a connection pool have? is there any upper limit on it?
2. How do we calculate how many connection pools we need for good performance in our OBIEE system.
3. Currently my client have plans to launch this application for 5,000 users and later after few months the same application will be opened for 70,000 users. So how should i calculate the number of connection pools required so that all the users can acces the Dashboard without feeling much network traffic (assuming all the users are logged in same time)
Any suggestions guys?Hi Abhi,
To calculate maximum no of connections go through the gerard nico link that Srikanth has provided.Generally for init blocks and report queries we creat diffrent connection pools.
No of connection pools and max no of connections should be carefully chosen because BI server will allocate memory to these connection even if you are not using those connection pools.Total no of connections in RPD should be less than 800.This is an Oracle recommnedation.
Regards,
Sandeep -
I am using odp.net 10gR2. Is there a way I can monitor the connection pool, like action connection, connection strings or active connections etc. Also, can I know the like how many connection pools will be there per cpu in my server and can I make any of the connection pool as inactive or disable or something like that ?
Thanks,Hi,
isn't the theory that there is no direct guaranteed mapping between connections -> sessions -> process ?!
atleast on 10.2.0.1 x64 on windows 2003 i'm chasing a issue where v$session and v$process counts do not correspond to the number of thread in the oracle.exe process. Seems like as the connection pools increase the threads go up as you would expect but then stay idle until the client app restarts (also a bug with Dead connection detections and keepalives with this release potentially).
anybody else with this kind of issue or more insight or even better a method to get a bit more insight?
thanks -
Clarification needed on JDBC Connection Pool in Clustered enviornment
Hi All,
Although I went through the bea online documentation , its not clear how
JDBC connection pool works in clustered environment.
If anyone can please answer following questions, it would be a great help.
1) Do I need to create identical connection pools (with identical ACLs) on
each WebLogic Server in the cluster ?
2) Online documentation says " If you create an identical JDBC DataSource in
each clustered WebLogic Server instance and configure those DataSources to
use different connection pools, the cluster can support load balancing for
JDBC connections. " what actually this means
3) What's the use of "JDBC MultiPools " ? Is it same as "JDBC metapool "
Thanks
Regards
Nalika
See comments inline...
Nalika wrote:
> Hi All,
>
> Although I went through the bea online documentation , its not clear how
> JDBC connection pool works in clustered environment.
> If anyone can please answer following questions, it would be a great help.
>
> 1) Do I need to create identical connection pools (with identical ACLs) on
> each WebLogic Server in the cluster ?
I don't believe that it is strictly necessary to do this but it is certainly the
most common configuration and probably the preferred one as well. WLS is smart
enough to automatically use its Type 3 driver to route requests to a connection
on another server but this type of server-to-server communication can have an
impact on performance and scalability.
> 2) Online documentation says " If you create an identical JDBC DataSource in
> each clustered WebLogic Server instance and configure those DataSources to
> use different connection pools, the cluster can support load balancing for
> JDBC connections. " what actually this means
Don't read too much into this. All that this is saying is that application
components in each server will "prefer" to use their local DataSource (all other
things being equal) and since other clustering technology (or things like
hardware load balancers) are spreading the load across the servers, you will
also spread the load across the different connection pools.
> 3) What's the use of "JDBC MultiPools " ? Is it same as "JDBC metapool "
Yes, these are one and the same.
Hope this helps,
Robert
-
How to create a connection pooling in Netbeans 6.0 using the oracle driver
hi all,
I am using Netbeans 6.0. Apache Tomcat 6.0.14 server, oracle 9i.
I tried to create a connection pooling using tomcat web server.
I have included the following code in context.xml and web.xml.
CONTEXT.XML:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/network1">
<Resource name="jdbc/myoracle"
auth="Container"
type="javax.sql.DataSource"
username="scott"
password="tiger"
factory="BasicDataSourceFactory"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:odbc:thin:@127.0.0.1:1521:mydb"
maxActive="20"
maxIdle="10"
maxwait="-1"/>
</Context>
WEB.XML:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>jdbc/myoracle</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
After that i have included the following JDBC driver's jar files in the $Catalina_Home/lib folder.
classes 111.jar,
classes 111_g.jar
classes12.jar
classes 12_g.jar
classes12dms.jar
classes12dms_g.jar
nls_charset11.jar
nls_charset12.jar
ocrs12.jar
ojdbc14.jar
ojdbc14_g.jar
Then i stop the tomcat web server and start it again.
In jsp page i have included the following code:
Context ctx=new InitialContext();
Context envctx=(Context)ctx.lookup("java:comp:env");
DataSource ds=(DataSource)envctx.lookup("jdbc/myoracle");
Connection con=ds.getConnection(); ----->(In this line an error occured that Connection class cannot be found.)
please help me how to create a connection pooling and rectify the error in conneciton.
Thanks in advancePlease refer
http://www.netbeans.org/kb/60/web/customer-book.html -
How do I create a non-JTS sequence connection pool using JTS
I'm getting all kinds of errors (DB deadlocks and exceptions) using JTS with sequences. From reading several posts, it is necessary to create a separate non-JTS connection pool.
I've seen several postings on how to do this in the sessions.xml file, but how do I do this in Java code?
What I am trying is:
SequencingControl seqCtrl = ((oracle.toplink.publicinterface.DatabaseSession)serverSession).getSequencingControl();
seqCtrl.setShouldUseSeparateConnection(true);
seqCtrl.setLogin(sequenceLogin);
I've also tried:
serverSession.addConnectionPool("sequencing", sequenceLogin, 2,5);
but neither work. The problem with these settings is that the sequence properties on my DatabaseLogin are not honored.
My table name is T_SEQUENCES and my preAllocation size is 5. However the SQL that is generated by this setup is:
"UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + 50 WHERE SEQ_NAME = 'T_GROUPS_SEQ'"
I'm guessing these may be default values, but I don't know where else to override these except for on the DatabaseLogin I am passing in.
I know this setup works, because it is the same DatabaseLogin I use for non-JTS configuration.
Could someone provide me a code-snippet on how to do this?
Thanks,
NateI'm not using XML files, all of my setup is in code. I'm not sure how I would use the setLoginAndApplySequenceProperties(DatabaseLogin) call or if it would address my larger problem.
The main issue I don't want to lose here is, I've got an application where I'm trying to use JTS with JBoss and SQL Server. It's a SessionBean/POJO architecture. The problem I was having that started this thread is that sequence number allocation causes a database deadlock.
My thought was if I opened a 2nd connection pool dedicated to sequences, it might resolve the issue. I was able to do this with the workaround I posted, but it didn't fix anything. I now get a different error related to my newly inserted objects.
From working with this off-and-on over the last several months, I would say that I don't think TopLink/JBoss/SQL Server using JTA can be made to work.
I know that TopLink has a plug-in architecture and in theory if I implemented ExternalTransactionController and SynchronizationListener for JBoss correctly, it should all work.
But, I've got the JBoss 4.0.0 source that I can step through, I've got all the recent updates to SQL Server and the JDBC driver, and I'm following everything I've been told so far on how to make this all work.
It plain doesn't work.
Furthermore, I haven't found anyone (this group, JBoss group) that has gotten this to work (TopLink/JBoss/JTA). This is an important item to us, we'd like to get this to work, and we would be happy to work with Oracle Consulting on this or whatever it takes (already opened a TAR on this).
Are there any other support options available to making this work?
Nate -
How can i improve database connectivity with connection pool
Hi,
I used to create a connection to DB per session since the application is pretty small. Now i want to improve the db connectrion with connection pool. However, i am still confused since the book i read says that i have to change something in server.xml in the tomcat server while other people in this forum actually implement a connection pool class. Isnt it has been built into the servlet container? if yes, how can i use it? I suppose i only have to open the connection and the connection pool will reclaim the resource when the session is terminated in the same way the gabage collector reclaim resource when no reference is associated to object, am i correct?
Thaithe documentation for Tomcat 5 DB pooling can be found at:
http://jakarta.apache.org/tomcat/tom...les-howto.html
Here are the Tomcat 4 docs:
http://jakarta.apache.org/tomcat/tom...les-howto.html
The administration console can be found at (under default install):
http:localhost:8080/admin
But, you have to set up a user and password in your
<tomcat-install>/conf/tomcat-users.xml file.
You need to add an "admin" role and a user that will be assigned this
role like this (obviously you won't be using "tomcat" as your password):
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="admin"/>
<user username="tomcat" password="tomcat" roles="admin"/>
</tomcat-users>
So, I can log in as Tomcat and have admin privs.
Tomcat 5
http://jakarta.apache.org/tomcat/tom...ger-howto.html
Tomcat 4
http://jakarta.apache.org/tomcat/tom...ion%20A ccess
i'm sure this helps u -
How to use Connection pool in Reports
Dear All,
Please help me How to create Connection pool for Reports and How to use in Reports.
Present i am using the report by passing parameter as P_JDBCPDS=username/password@databaseName. I thought this will not manage the coonection pool.
For all reports and every time i am passing userName/password, how to avoid this. Please help me.
1. How to create Connection pool for Report Server
2. How to use that Connection pool in the Reports.
Please help me.
With Regards,
Srinivas.Until now, I have not worked unfortunately with a connection pool, but, I have found a documentation about the Creating an Internal Connection Pool.
http://download-east.oracle.com/docs/cd/B25221_04/web.1013/b13593/cpdef.htm -
Rookie Problem:Connection Pool Class not found
Hi All,
I'm new to java (3 days now!) and I was writing some sample JSP code to learn about Connection Pooling using Sun Server 8... My goal here is to hopefully learn how to use Connection pooling so I can develop a DAO class that uses good design patterens. It appears that that my J2EE server is not finding my db providers connection pooling class. If this is my problem where should I add this reference? I was looking at the Admin Console and did not see a way to add it there?
Someone please send me down the right path :)
I think my error is...."Wrong class name or classpath for Datasource Object : {0}
java.lang.ClassNotFoundException: com.ibm.db2.jdbc.DB2ConnectionPoolDataSource" (see below for trace)
Thanks in advance for the help and tips
John
My test JSP source code......
<%/* JMM This page was created on 9/1/2004
The purpose of this page is to test and learn basic JSP Connection Snytax and flow
control */%>
<%/* **********Begin JSP Page Directives********** */%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="javax.sql.*"%>
<%@page import="java.sql.*"%>
<%@page import="javax.naming.*"%>
<%@page import="java.util.Hashtable"%>
<%/* ********** End JSP Page Directive ********** */%>
<%! String pageName = "Johns Test JSP Page";
String jndi_ereporting_nm = "jdbc/F0654TE1";
%>
<html>
<head><title><%=pageName%></title></head>
<body>
<%-- <jsp:useBean id="beanInstanceName" scope="session" class="beanPackage.BeanClassName" /> --%>
<%-- <jsp:getProperty name="beanInstanceName" property="propertyName" /> --%>
Importing the follwoing Libs<br>
<br>import javax.sql.*;
<br>import java.sql.*;
<br>import javax.naming.*;
<br>import java.util.Hashtable;
<br>
<br>Attempting to connnect to F0654TE1 using JNDI Lookup....
<br>
<%
DataSource ds = null;
Connection con = null;
Context ctx = null;
Hashtable env = null;
long nStartTime, nStopTime, nElapsedTime;
// Set up environment for creating InitialContext object
//humm.. whats stored in here ....what are these used for?
out.println("Context.INITIAL_CONTEXT_FACTORY=" + Context.INITIAL_CONTEXT_FACTORY + "<br>");
out.println("Context.PROVIDER_URL=" + Context.PROVIDER_URL + "<br>");
InitialContext ic = new InitialContext();
ds = (DataSource) ic.lookup(jndi_ereporting_nm);
out.println("open connection....<br>");
con = ds.getConnection();
out.println("connection has been opened!!!....<br>");
con.close();
out.println("connection has been closed!!!....<br>");
%>
<br>
<br>Finished attempting to connnect to F0654TE1 using JNDI....
</body>
</html>
Errror Log file.....
[#|2004-09-02T10:08:42.951-0400|SEVERE|sun-appserver-pe8.0.0_01|javax.enterprise.resource.resourceadapter|_ThreadID=11;|RAR5099 : Wrong class name or classpath for Datasource Object : {0}
java.lang.ClassNotFoundException: com.ibm.db2.jdbc.DB2ConnectionPoolDataSource
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at com.sun.gjc.common.DataSourceObjectBuilder.getDataSourceObject(DataSourceObjectBuilder.java:198)
at com.sun.gjc.common.DataSourceObjectBuilder.constructDataSourceObject(DataSourceObjectBuilder.java:65)
at com.sun.gjc.spi.DSManagedConnectionFactory.createManagedConnection(DSManagedConnectionFactory.java:70)
at com.sun.enterprise.resource.LocalTxConnectorAllocator.createResource(LocalTxConnectorAllocator.java:63)
at com.sun.enterprise.resource.IASNonSharedResourcePool.createSteadyResources(IASNonSharedResourcePool.java:501)
at com.sun.enterprise.resource.IASNonSharedResourcePool.initPool(IASNonSharedResourcePool.java:176)
at com.sun.enterprise.resource.IASNonSharedResourcePool.internalGetResource(IASNonSharedResourcePool.java:314)
at com.sun.enterprise.resource.IASNonSharedResourcePool.getResource(IASNonSharedResourcePool.java:260)
at com.sun.enterprise.resource.PoolManagerImpl.getResourceFromPool(PoolManagerImpl.java:244)
at com.sun.enterprise.resource.PoolManagerImpl.getResource(PoolManagerImpl.java:137)
at com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:194)
at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:94)
at com.sun.gjc.spi.DataSource.getConnection(DataSource.java:68)
at org.apache.jsp.jsp.jndi_005fdb_005ftest_jsp._jspService(jndi_005fdb_005ftest_jsp.java:102)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:102)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:861)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:282)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:263)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:210)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:861)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:246)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:268)
at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:236)
at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:145)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:141)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:168)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:144)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:133)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:539)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107)
at com.sun.enterprise.webservice.EjbWebServiceValve.invoke(EjbWebServiceValve.java:134)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107)
at com.sun.enterprise.security.web.SingleSignOn.invoke(SingleSignOn.java:254)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107)
at com.sun.enterprise.web.VirtualServerValve.invoke(VirtualServerValve.java:209)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:114)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109)
at com.sun.enterprise.web.VirtualServerMappingValve.invoke(VirtualServerMappingValve.java:166)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:936)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:165)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:683)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:604)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:542)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:647)
at java.lang.Thread.run(Thread.java:534)
|#]
[#|2004-09-02T10:08:42.961-0400|WARNING|sun-appserver-pe8.0.0_01|javax.enterprise.resource.resourceadapter|_ThreadID=11;|RAR5038:Unexpected exception while creating resource|#]
[#|2004-09-02T10:08:42.961-0400|WARNING|sun-appserver-pe8.0.0_01|javax.enterprise.resource.resourceadapter|_ThreadID=11;|RAR5117 : Failed to obtain/create connection. Reason : Class name is wrong or classpath is not set for : com.ibm.db2.jdbc.DB2ConnectionPoolDataSource|#]
[#|2004-09-02T10:08:42.961-0400|WARNING|sun-appserver-pe8.0.0_01|javax.enterprise.resource.resourceadapter|_ThreadID=11;|RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: Class name is wrong or classpath is not set for : com.ibm.db2.jdbc.DB2ConnectionPoolDataSource]|#]
[#|2004-09-02T10:08:43.131-0400|SEVERE|sun-appserver-pe8.0.0_01|javax.enterprise.system.container.web|_ThreadID=11;|StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
java.sql.SQLException: Error in allocating a connection. Cause: Class name is wrong or classpath is not set for : com.ibm.db2.jdbc.DB2ConnectionPoolDataSource
at com.sun.gjc.spi.DataSource.getConnection(DataSource.java:72)
at org.apache.jsp.jsp.jndi_005fdb_005ftest_jsp._jspService(jndi_005fdb_005ftest_jsp.java:102)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:102)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:861)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:282)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:263)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:210)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:861)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:246)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:268)
at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:236)
at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:145)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:141)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:168)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:144)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:133)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:539)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107)
at com.sun.enterprise.webservice.EjbWebServiceValve.invoke(EjbWebServiceValve.java:134)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107)
at com.sun.enterprise.security.web.SingleSignOn.invoke(SingleSignOn.java:254)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107)
at com.sun.enterprise.web.VirtualServerValve.invoke(VirtualServerValve.java:209)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:114)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109)
at com.sun.enterprise.web.VirtualServerMappingValve.invoke(VirtualServerMappingValve.java:166)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:936)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:165)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:683)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:604)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:542)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:647)
at java.lang.Thread.run(Thread.java:534)
|#]Sorry this is not the way i usually handle db connectivity, i think you need to set up a name in your server.xml file (this is for tomcat based applicatin servers) which is then referenced in your jsp file. I have had a quick google and found this.
http://manual.evolutionhosting.com/evochunk/ch19s04.html
You menttioned that you wanted to devolp really good design patterns, how big is your project going to be, if it is going to be a large project then you may want to look at
http://www.hibernate.org
Maybe you are looking for
-
Third Party database connections not present
I just downloaded the latest production build: 3.0.04.34 and I'm trying to setup a migration from MSSQL Server to Oracle, but the only connection options I am given are for Oracle and Access. This, in spite of the fact that all the 3.0 documentation
-
Hello! So I've just bought myself a Pioneer A4 (XWSMAK4) which sounds great, works beautifully with Windows 8 'Play To' from within WMP/explorer and Airplay is dead easy. http://www.pioneer.com.au/au/products/42/202/227/XW-SMA4-K/page.html What I wa
-
LMS 3.2.1 integration with Clarity NMS for snmp trap forwarding
Our client have integrated Clarity NMS to Ciscoworks LMS 3.2.1. So far they are receiving raw alarms/snmp traps but it lacks information/inventory of the originating device. Kindly see sample raw alarms below: 2420: 2011-11-25 12:10:46 Received trap
-
Compound clip imported into project not showing up in the event browser
I have learnt that when one imports any clip into the project from anywhere else other than its associated event folder, the new clip also gets automatically added into the event folder. I have seen this occur when I had imported audio from the music
-
Iphone 4 is unlocked or not?
If I buy a phone from apple retail store then will it be locked by any carrier or can I use it with any carrier I want? Is it unlocked by apple itself or do I need to unlock myself?