How to use connection pool of datasource to make applications run faster?
Hi, erveryone
I prepare to implement a servlet that access database and do sync with client.
When I access database, I would like to configure a datasource in weblogic and use connection pool.
In order to make servlet application run significantly faster, my servet how to use connection poo is much moreresonable?
For example, my servlet has many times database access. Is it true that geting and close a connection whenever
one time database access finished?
If from the servlet begins, the db connection is hold till servlet finalize. Will the solution affect the servlet performance? Is there any official document to introduce connection pool program? I search some documents.
<The Java EE 6Tutorial> introduce some simple intruduction about connection pool.
1. Use WebLogic Servers Data Source for Database Connections.
2. Open and close the connections where you need it. Dont open it in begin and close in finalise. That is bad practice.
3. Even when you invoke Connection.close () webLogic will not close the connection. it will commit the transaction and return it back to the pool rather than physically closing the DB connection.
4. You can tune data source for minimum, maximum and increments of connections that you need based on your application requirement.
Similar Messages
-
How to use Connection Pool in ADF ear file creaion from jDev 10.1.3
Hi,
We are developing big application in ADF with 10 different modules. We are creating ear file with data source setting.
How to use connection pool while creating ear file from jDev. Connection pool is alreday created in Application Server 10g.
What all the setting we need do to make use of connection pool while creating ear file jDev.
ThanksUser,
If you are using ADF Business Components, you can right-click each application module, select "configurations" and edit the configuration you are using. On the initial page of the configuration dialog, you can specify to use either a JDBC URL or a Datasource - you just need to choose Datasource and then provide the name by which to access it.
John -
How To Use Connection Pooling in Struts.
Can Somebody have the idea how to use connection pooling. i want to use jakarta commons dbcp, pool.
using these packages how can i implement the connection pooling for my web application. If Anybody have some idea plz contect me.
If Somebody have sample code plz send.
Thks in Advance,Read the documentation...?
-
How to retain connection pool resource while exporting the application war
hello,
lately i have figured out how to use connection pooling. now i have another issue.
i have to export the application war file to a remote server for deployment. i cant configure the server.xml file there due to restrictions. Now is there any way that i can retain the connection pooling with all JNDI resources while exporting the war file. what all things would i have to do. i am using tomcat 4.1 and the remote server too have the same appliaction server running.
is this possible?
thanks in advanceHi,
you might have the problem in creating WAR files.
lease check that first.
thanks,
nvseenuNo, the problem is that you shouldn't be modifying the server.xml
The proper, portable way to do it is to create a context.xml file and put it in the META-INF directory of your WAR file. This contains your Resource definition and JDBC connection parameters. Everything's portable that way.
I know this works on Tomcat 5.x.
It can also work with Tomcat 4.1.x, but the way I've done it is to put the context.xml into a file whose name matches my WAR file (e.g, foo.war and foo.xml), placing both in the /webapps directory. Tomcat 4.1.x picks it up that way.
It would be worth an experiment to see if Tomcat 4.1.x picks up the context from /META-INF, because that way your WAR file is 100% portable.
This is precisely the reason why I advise people not to edit the server.xml. You don't always have the option to do so.
% -
How to use connection pooling in JDev 10.1.2
In all the ADF apps I have created, I have always used the defined connection in JDev and deployed the password. I'm now being told I need to stop doing that and start using oc4j connection pool with datasource definition so the passwords won't have to be deployed.
I pretty much need step by step instructions on how to do this becasue I've never done it. Any help would be greatly appreciated. Thanks.Hi,
How about these tutorials?
http://www.oracle.com/technology/tech/java/newsletter/articles/oc4j_data_sources/oc4j_ds.htm
http://www.oracle.com/technology/products/jdev/tips/duff/mysql_and_oc4j3.html -
How to use connection pool with RDBMSRealm
I am having a problem with the RDBMSRealm. The problem is that the connection defined in the .realm_properties file times out after 1 hour. My solution was to use the connection pool defined in the weblogic.properties file, but the realm_proprties are read before the connection pool is created so it did'nt work.Is there anyway of controling the order of which WLS reads various properties?If no, is there any way of setting "autorefresh" on the connection defined in the .realm_properties file?I'am using WLS 5.1, S.P 8, WIN2000 and Sybase. It works fine except for the timeout.Please help-Marius
I've been struggling to find a way to use a weblogic connection
pool or datasource nicely, and have failed with whatever I've tried.
There is a chicken and egg problem here. The connection pool needs
security to initialize itself, and security needs a connection
pool. So that will not work.
I've tried the follwing, which almost worked. Weblogic falls
back to the default realm if your custom realm returns null for
any user or group requests. So if your custom realm is not capable
of reading info from the database, return null. The default realm
will take over, and allow the connection pool to initialize if
you allow everybody (or users defined in the weblogic.properties
file) access to the pool. Then define a datasource which points
to the pool.
After the server starts, security can then use JNDI to look up
the datasource, and all seems well. However, in some instances
(it seems like calls for a bean), where security and jndi can get
into infinite loops where jndi performs a security check when doing
the lookup, so they both end up asking each other for information.
So if anyone knows how to successfully use a connection pool or
DataSource in a custom realm, I would love to know how.
For you, I would suggest you don't try and use a connection pool,
but figure out how to refresh your connection. You can do it manually
by taking your connection, checking if it's valid before using
it, if not, then open a new one.
-d-
Marius <[email protected]> wrote:
I am having a problem with the RDBMSRealm. The problem
is that the connection defined in the .realm_properties
file times out after 1 hour. My solution was to use the
connection pool defined in the weblogic.properties file,
but the realm_proprties are read before the connection
pool is created so it did'nt work.Is there anyway of
controling the order of which WLS reads various properties?If
no, is there any way of setting "autorefresh" on the
connection defined in the .realm_properties file?I'am
using WLS 5.1, S.P 8, WIN2000 and Sybase. It works fine
except for the timeout.Please help-Marius -
How dynamically create connection pool and Datasource
Hi
How I can dynamically create a connection pool and Data source in Oracle 10g Application server. In our J2EE application the user will be login with db user name, password and database name. I want to create connection pool and data source on the fly while login the user with database name. I our application we have access approximate 80 Databases. so my approach is given bellow
1) Planning to create 80 connection pools and 80 Data sources so when user logs in while selecting the db name i will call the appropriate data source and create the DB connection. Is there any limitation to create number of data sources in oracle app server?
2) Create DB connection with out using connection pool and data source. But i am not prefer this approach coz we need to handle some transaction in our application.
Kindly throw some light on managing connection pool programmatically or in application run time.
I would really appreciate if any one can provide any links or any inormation on this issue.
Thanks in advance.Kindly let me know is there any drawbacks to create 80 Data Sources to connect 80 database in Oracle 10G App server and each data sources should have one connection pool. so i need to create 80 connection pool. Please let me know is this right approach or any work around to create Data source on fly for each request for corresponding database.
-
How to use Connection Pool on WLS 10.0 MP2?
Hello there!
I have a WS and i use ibatis to talk iwth a Oracle DB, but i have a requirement to use connection pool by wls and i dont where should i do this to my application.
I just have this method to the connection
private static void initDb() throws IOException, SQLException {
log.info("Conectando a bd");
String sqlMapResource = "com/app/activacion/db/sqlMapConfig.xml";
Reader reader = Resources.getResourceAsReader(sqlMapResource);
SqlMapClient sqlMapClientIbatis =
SqlMapClientBuilder.buildSqlMapClient(reader,properties);
List<String> n = (List<String>) sqlMapClientIbatis.queryForList("test");
log.debug("n: " + n);
log.info("Conexion a BD realizada.");
And my sqlMapConfig.xml is
<sqlMapConfig>
<settings cacheModelsEnabled="true"
enhancementEnabled="true"
lazyLoadingEnabled="true"
maxRequests="320"
maxSessions="128"
maxTransactions="32"/>
<transactionManager type="JDBC">
<dataSource type="DBCP">
<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
<property name="url" value="${db.connectionURL}" />
<property name="username" value="${db.username}" />
<property name="password" value="${db.password}" />
</dataSource>
</transactionManager>
<sqlMap resource="com/epcs/facturacionpostpago/activacionbb/db/statements.xml" />
</sqlMapConfig>
Can u give me an advice to set the connection pool please?
Thanx in advance!
Edited by: mgaldames on 02-jun-2010 10:54According to a google hit, it looks like you should be able to do something like this:
http://www.j2eegeek.com/blog/2005/01/31/ibatis-where-have-you-been-all-my-life/
First, configure a datasource in the wls console, the example uses:
jdbc/jpetstoreDS
as the JNDI name.
Then it looks like the following syntax works for the mapping that refers to that datasource, keep in mind your servername/port may be different.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd"?>
<sqlmapconfig>
<settings cacheModelsEnabled="false" enhancementEnabled=" true" lazyLoadingEnabled="true"
maxRequests="32" maxSessions="100" maxTransactions="100" useStatementNamespaces="false"/>
<transactionmanager type="JDBC">
<datasource type="JNDI">
<property name="context.java.naming.factory.initial" value="weblogic.jndi.WLInitialContextFactory"/>
<property name="context.java.naming.provider.url" value="t3://localhost:7001"/>
<property name="DataSource" value="jdbc/jpetstoreDS"/>
</datasource>
</transactionmanager>
<sqlmap resource="com/j2eegeek/ibatis/dao/maps/Account.xml"/>
</sqlmapconfig> -
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 -
How To Use Connection pooling with j2sdkee1.3?
hi!
How to use javax.sql.ConnectionPoolDataSource and
javax.sql.PooledConnection with j2sdkee1.3.?
In j2ee1.3's deployment tool,
to specify the resource factories,
javax.sql.ConnectionPoolDataSource is not available.
Please Help me to use Connection pooling.
Dhaya.Vendor implementations usually have a fair amount of optimization. For J2EE apps, my concern would be using your pool in transactional calls. When you make a transactional call across several beans/methods, the vendor's pool makes sure that you get the same connection each time you get a connection from the pool so that if you want to rollback the work (in case an error occurs), you can. Does your current connection pool support this?
-
How to use connection pool in struts
hai
I have created my own connection pool class. I need to use the connection pool in my struts application. Can anyone tell me where and how to implement ,Please....
Thanks in advance.User,
If you are using ADF Business Components, you can right-click each application module, select "configurations" and edit the configuration you are using. On the initial page of the configuration dialog, you can specify to use either a JDBC URL or a Datasource - you just need to choose Datasource and then provide the name by which to access it.
John -
How to use connection pooling in jsp?
I'm new to world of JSP. I'm developing web application using Oracle 8i and JSP to implement it. I'm using jakarta-tomcat server for this purpose.
I'll frequently access the database. so I want to use the connection pooling.
Can anybody explain the simple procedure to use it
thanxHello syyuen,
Please help me, here iam sending u my server.xml , web.xml and servlet
application. I put classes12.jar in tomcat/common/lib. and above servlet
class application under tomcat/webapps/root/web-inf/classes
and this is a simple servlet program for getting connection from the
connection pool of tomcat using tyrex..
my oracle database name is "myuser" and password is "mypass"
either u check my server.xml or tell me where under which tag should i
place <Resource...> tag in server.xml and should i need to modify any
other places..??
server.xml
<Server port="8005" shutdown="SHUTDOWN" debug="0">
<!-- Tomcat Stand-Alone Service -->
<Service name="Tomcat-Standalone">
<!-- Non-SSL HTTP/1.1 Connector on port 8080 -->
<Connector className="org.apache.catalina.connector.http.HttpConnector"
port="8080" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="60000"/>
<!-- AJP 1.3 Connector on port 8009 -->
<Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
port="8009" minProcessors="5" maxProcessors="75"
acceptCount="10" debug="0"/>
<!-- Top level container in our container hierarchy -->
<Engine name="Standalone" defaultHost="localhost" debug="0">
<!-- Global logger unless overridden at lower levels -->
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="catalina_log." suffix=".txt"
timestamp="true"/>
<!-- Because this Realm is here, an instance will be shared globally
<Realm className="org.apache.catalina.realm.MemoryRealm" /> -->
<!-- Replace the above Realm with one of the following to get a Realm
stored in a database and accessed via JDBC -->
<!-- <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="org.gjt.mm.mysql.Driver"
connectionURL="jdbc:mysql://localhost/authority?user=test;password=test"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="oracle.jdbc.driver.OracleDriver"
connectionURL="jdbc:oracle:thin:@oracle:1521:ORCL"
connectionName = "mail"
connectionPassword = "mail"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
<!-- <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="sun.jdbc.odbc.JdbcOdbcDriver"
connectionURL="jdbc:odbc:CATALINA"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
<!-- Define the default virtual host -->
<Host name="localhost" debug="1" appBase="webapps" unpackWARs="true">
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common"/>
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>
<!-- Tomcat Root Context -->
<!-- <Context path="" docBase="ROOT" debug="0"/> -->
<!-- Tomcat Manager Context -->
<Context path="/manager" docBase="manager" debug="0" privileged="true"/>
<!-- MY CONTEXT HERE -->
<Context path="/localhost" docBase="localhost" debug="0" reloadable="false" override="true">
<Resource name="jdbc/myConnection" auth="SERVLET" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/myConnection">
<parameter><name>user</name><value>myuser</value></parameter>
<parameter><name>password</name><value>mypass</value></parameter>
<parameter><name>driverClassName</name><value>oracle.jdbc.driver.OracleDriver</value></parameter>
<parameter>
<name>url</name>
<value>jdbc:oracle:thin:@oracle:1521:ORCL</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>32</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>10</value>
</parameter>
</ResourceParams>
<!-- END OF MY Context, Oracle username=myuser,password=mypass -->
<!-- i pasted this context from somebody . should i need whole context or resource name in that...???? -->
<!-- Tomcat Examples Context
<Context path="/examples" docBase="examples" debug="0" reloadable="true" crossContext="true">
-->
<!--
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_examples_log." suffix=".txt" timestamp="true"/>
<Ejb name="ejb/EmplRecord" type="Entity" home="com.wombat.empl.EmployeeRecordHome" remote="com.wombat.empl.EmployeeRecord"/>
<Environment name="maxExemptions" type="java.lang.Integer" value="15"/>
<Parameter name="context.param.name" value="context.param.value" override="false"/>
<Resource name="jdbc/EmployeeAppDb" auth="SERVLET" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/EmployeeAppDb">
<parameter><name>user</name><value>sa</value></parameter>
<parameter><name>password</name><value></value></parameter>
<parameter><name>driverClassName</name><value>org.hsql.jdbcDriver</value></parameter>
<parameter><name>driverName</name><value>jdbc:HypersonicSQL:database</value></parameter>
</ResourceParams>
<Resource name="mail/Session" auth="Container" type="javax.mail.Session"/>
<ResourceParams name="mail/Session">
<parameter>
<name>mail.smtp.host</name>
<value>localhost</value>
</parameter>
</ResourceParams>
-->
</Context>
</Host>
</Engine>
</Service>
<!-- Define an Apache-Connector Service -->
<Service name="Tomcat-Apache">
<Connector className="org.apache.catalina.connector.warp.WarpConnector"
port="8008" minProcessors="5" maxProcessors="75"
enableLookups="true" appBase="webapps"
acceptCount="10" debug="0"/>
<!-- Replace "localhost" with what your Apache "ServerName" is set to -->
<Engine className="org.apache.catalina.connector.warp.WarpEngine"
name="Apache" debug="0">
<!-- Global logger unless overridden at lower levels -->
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="apache_log." suffix=".txt"
timestamp="true"/>
<!-- Because this Realm is here, an instance will be shared globally -->
<Realm className="org.apache.catalina.realm.MemoryRealm" />
</Engine>
</Service>
</Server>
web.xml
<web-app>
<servlet>
<servlet-name>conServlet</servlet-name>
<servlet-class>conServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>conServlet</servlet-name>
<url-pattern> /conServlet </url-pattern>
</servlet-mapping>
<resource-ref>
<description> Resource reference to java.sql.Connection
factory defined in server.xml
</description>
<res-ref-name>jdbc/myConnection</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
servlet application
DataSource ds = (DataSource) new InitialContext().lookup("java:comp/env/jdbc/myConnection");
conn = ds.getConnection();
out.println("conn : " + conn); -
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 -
How to use connection pooling in 6.5 from standalone application?
Hi,
Is it possible to standalone application get connection from connection pool Sun ONE App Server 6.5?
If can means how pls tell me the steps?
I am trying standalone application to get connection from pool it will throw StackOverflowError.
thanks
with regds
parthiHi,
Is it possible to standalone application get connection from connection pool Sun ONE App Server 6.5?
If can means how pls tell me the steps?
I am trying standalone application to get connection from pool it will throw StackOverflowError.
thanks
with regds
parthi -
How to tune a oracle sql query to make it run faster ...
Hi Guys,
I am very new to this tuning of sql queries. It is taking a lot of time to run a query and give the output. I have a tool called TOAD[ Tool for oracle application development ] and i ran a query in that tool. Its showing that the query is taking 7sec to get its output. I donno the exact procedure what to follow in order to tune that query. What are these actually like : explain plan, sqltrace, tkprof and how to use these to tune the query. I want my query to run faster like in msec.
Help Appreciated.
Thankshttp://download-east.oracle.com/docs/cd/B10501_01/server.920/a96533/toc.htm
http://download-east.oracle.com/docs/cd/B10501_01/server.920/a96533/sqltrace.htm#1018
Maybe you are looking for
-
I have many songs and playlists in my iTunes account. I do not want all of them synced to my iPhone 5S, but that has happened via iCloud, and it has caused a storage problem on my phone. How do I select only certain playlists to be synced to my iPh
-
Hi, I have registered at apple site, and i have submitted the credit card information, they deducted some ammount without my permission, why they did that? how can i remove my credit card details from that site or deactivate my account?
-
OracleBIAnalyticsApps.rpd configuration
Hi, I have a OracleBIAnalyticsApps.rpd for all EBS modules. Could you tell me please if there's a way to limit in Physical, Business and Presentation layers the displayed objects to a specific module (for example I want to have only the information r
-
Marketing execution over the top of ORDM ?
We are implementing ORDM here for its MIS/BI capabilities and have noted that most of the Data Mining and Analytics that the Marketing team use in their own tool (Alterian) exist within BI (segment analysis / basket analysis / promotion analysis etc)
-
I've tried my iPod Touch, Shuffle, my iPhone 4, and my other halfs Nano and nothing. It syncs when I open iTunes but it has also stopped opening Last FM and scrobbling also. Do I need to do a reinstall?