Connection pool for big web application
hi,
i am developing an application which had more then 20 classes and each class use databases.
i made an connection bean and use it for database connectivity but as my code expand and my application run for longer time i start getting error of connection limit.
then i start using connection pool. in this i start using one connection for whole application.
now i want that my
1-whole application use that connection pool and i dont need to initialize it in different classes.
2- The main problem is that may at a time i have to connect database with different user and these connections should remain active.
my application will be used for enterprise level and remain active for months .
following is my connection pool
public class ConnectionPool implements Runnable
private Log log=new Log();
private String driver, url, username, password;
private int maxConnections;
private boolean waitIfBusy;
private Vector availableConnections, busyConnections;
private boolean connectionPending = false;
public ConnectionPool(String driver, String url,String username, String password,int initialConnections, int maxConnections, boolean waitIfBusy)
this.driver = driver;
this.url = url;
this.username = username;
this.password = password;
this.maxConnections = maxConnections;
this.waitIfBusy = waitIfBusy;
if (initialConnections > maxConnections)
initialConnections = maxConnections;
availableConnections = new Vector(initialConnections);
busyConnections = new Vector();
try
for(int i=0; i<initialConnections; i++)
availableConnections.addElement(makeNewConnection());
catch(Exception e)
log.write(e.getMessage());
}//EO constructor
public synchronized Connection getConnection()
if (!availableConnections.isEmpty())
log.write("Total connections="+availableConnections.size());
Connection existingConnection = (Connection)availableConnections.lastElement();
int lastIndex = availableConnections.size() - 1;
availableConnections.removeElementAt(lastIndex);
// If connection on available list is closed (e.g.,it timed out), then remove it from available list
// and repeat the process of obtaining a connection. Also wake up threads that were waiting for a connection because maxConnection limit was reached.
try
if (existingConnection.isClosed())
notifyAll(); // Freed up a spot for anybody waiting
return(getConnection());
else
log.write( "in available connection" );
busyConnections.addElement(existingConnection);
return(existingConnection);
catch(SQLException se)
log.write(se.getMessage());
} else {
// Three possible cases:
// 1) You haven't reached maxConnections limit. So establish one in the background if there isn't
// already one pending, then wait for the next available connection (whether or not it was the newly established one).
// 2) You reached maxConnections limit and waitIfBusy flag is false. Throw SQLException in such a case.
// 3) You reached maxConnections limit and waitIfBusy flag is true. Then do the same thing as in second
// part of step 1: wait for next available connection.
if ((totalConnections() < maxConnections) && !connectionPending)
makeBackgroundConnection();
else if (!waitIfBusy)
log.write("Connection limit reached");
// Wait for either a new connection to be established (if you called makeBackgroundConnection) or for
// an existing connection to be freed up.
try {
wait();
catch(InterruptedException ie)
log.write(ie.getMessage());
// Someone freed up a connection, so try again.
return(getConnection());
}//EO main if-else
return null;
}//EO getconnection method
// You can't just make a new connection in the foreground
// when none are available, since this can take several
// seconds with a slow network connection. Instead,
// start a thread that establishes a new connection,
// then wait. You get woken up either when the new connection
// is established or if someone finishes with an existing
// connection.
private void makeBackgroundConnection() {
connectionPending = true;
try {
Thread connectThread = new Thread(this);
connectThread.start();
} catch(OutOfMemoryError oome) {
// Give up on new connection
log.write(oome.getMessage());
public void run() {
try {
Connection connection = makeNewConnection();
synchronized(this) {
availableConnections.addElement(connection);
connectionPending = false;
notifyAll();
} catch(Exception e) { // SQLException or OutOfMemory
// Give up on new connection and wait for existing one free up.
log.write(e.getMessage());
// This explicitly makes a new connection. Called in
// the foreground when initializing the ConnectionPool,
// and called in the background when running.
private Connection makeNewConnection()
//log.write("make new connection with "+url+" "+username+" "+password +" and driver= "+driver);
Connection connection=null;
try
// Load database driver if not already loaded
//Class.forName(driver);
DriverManager.registerDriver(new OracleDriver());
// Establish network connection to database
connection = DriverManager.getConnection(url, username, password);
if( connection.isClosed() )
log.write("ooooooops no connection");
else
log.write("yahoooo get connection");
catch(Exception e)
log.write(e.getMessage());
return(connection);
public synchronized void free(Connection connection) {
busyConnections.removeElement(connection);
availableConnections.addElement(connection);
// Wake up threads that are waiting for a connection
notifyAll();
public synchronized int totalConnections() {
return(availableConnections.size() + busyConnections.size());
/** Close all the connections. Use with caution:
* be sure no connections are in use before
* calling. Note that you are not <I>required</I> to
* call this when done with a ConnectionPool, since
* connections are guaranteed to be closed when
* garbage collected. But this method gives more control
* regarding when the connections are closed.
public synchronized void closeAllConnections() {
closeConnections(availableConnections);
availableConnections = new Vector();
closeConnections(busyConnections);
busyConnections = new Vector();
private void closeConnections(Vector connections) {
try {
for(int i=0; i<connections.size(); i++) {
Connection connection =
(Connection)connections.elementAt(i);
if (!connection.isClosed()) {
connection.close();
} catch(SQLException sqle) {
// Ignore errors; garbage collect anyhow
log.write(sqle.getMessage());
}i get this code from internet, in which it also mention that use following code
public class BookPool extends ConnectionPool {
private static BookPool pool = null;
private BookPool(...) {
super(...); // Call parent constructor
public static synchronized BookPool getInstance() {
if (pool == null) {
pool = new BookPool(...);
return(pool);
}if some one want to use it for whole application then use connection pool by BookPool,
now main point is i m not getting the BookPool class could some one explain it to me???
and second by using it can i connect to different users of DB at a time, if cant then how i can.
its good if some one explain it by little code.
thxxxxxxxxxxxxxxxxxx
If this is a real, serious application and not just for practice, then why are you trying to write your own connection pool implementation?
You'd better use Jakarta's Commons Pool and Commons DBCP, which are widely used, well tested implementations of connection pools.
If this is a web application running in a J2EE container, you'd normally configure the connection pool in the container. The container will register the pool in JNDI and you'd look it up in JNDI from your application.
Here's some documentation on how to do that in Tomcat 5.5: JNDI Datasource HOW-TO
Similar Messages
-
Configure Service Principle Name for Application Pool account and web application?
Hello Community
On WS2012 Server running Sharepoint 2013 Server when you
configure SPN you configure it for the SQL server object "MSSQLSvc" (domain account)
and the user object "HTTP" (domain account).
The question is if you also should configure SPN for the Application Pool account and
configure SPN for the web application, how do you configure SPN for the Application Pool
account and the web application?
Thank you
ShabeautThe Web Application is only an IIS Site. You're configuring the SPN for the Domain User running the IIS Application Pool (that the Web Application (IIS Site) leverages).
So you would just need to use the format of:
setspn -A HTTP/webAppUrl domain\iisapppoolacctusername
setspn -A HTTP/webAppUrl.fqdn.com domain\iisapppoolacctusername
Trevor Seward
Follow or contact me at...
  
This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs. -
Has anyone run the connection pooling for mysql & tomcat successfully?
I'm trying to set up connection pooling. I'm following the how-to page at
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
But when i test the DBTest/test.jsp file, tomcat displays an error =
could not load jdbc driver class 'null'(msdos)
i have placed all the required .jar files in the tomcat lib.
below is the cofiguration i did to the server.xml file
<!-- Example Server Configuration File -->
<!-- Note that component elements are nested corresponding to their
parent-child relationships with each other -->
<!-- A "Server" is a singleton element that represents the entire JVM,
which may contain one or more "Service" instances. The Server
listens for a shutdown command on the indicated port.
Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" or "Loggers" at this level.
-->
<Server port="8005" shutdown="SHUTDOWN" debug="0">
<!-- Uncomment these entries to enable JMX MBeans support -->
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
debug="0"/>
<!-- Global JNDI resources -->
<GlobalNamingResources>
<!-- Test entry for demonstration purposes -->
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users -->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved">
</Resource>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" (and therefore the web applications visible
within that Container). Normally, that Container is an "Engine",
but this is not required.
Note: A "Service" is not itself a "Container", so you may not
define subcomponents such as "Valves" or "Loggers" at this level.
-->
<!-- Define the Tomcat Stand-Alone Service -->
<Service name="Tomcat-Standalone">
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Each Connector passes requests on to the
associated "Container" (normally an Engine) for processing.
By default, a non-SSL HTTP/1.1 Connector is established on port 8080.
You can also enable an SSL HTTP/1.1 Connector on port 8443 by
following the instructions below and uncommenting the second Connector
entry. SSL support requires the following steps (see the SSL Config
HOWTO in the Tomcat 4.0 documentation bundle for more detailed
instructions):
* Download and install JSSE 1.0.2 or later, and put the JAR files
into "$JAVA_HOME/jre/lib/ext".
* Execute:
%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA (Windows)
$JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA (Unix)
with a password value of "changeit" for both the certificate and
the keystore itself.
By default, DNS lookups are enabled when a web application calls
request.getRemoteHost(). This can have an adverse impact on
performance, so you can disable it by setting the
"enableLookups" attribute to "false". When DNS lookups are disabled,
request.getRemoteHost() will return the String version of the
IP address of the remote client.
-->
<!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8081 -->
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8080" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="100" debug="0" connectionTimeout="20000"
useURIValidationHack="false" disableUploadTimeout="true" />
<!-- Note : To disable connection timeouts, set connectionTimeout value
to -1 -->
<!-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
<!--
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8443" minProcessors="5" maxProcessors="75"
enableLookups="true"
acceptCount="100" debug="0" scheme="https" secure="true"
useURIValidationHack="false" disableUploadTimeout="true">
<Factory className="org.apache.coyote.tomcat4.CoyoteServerSocketFactory"
clientAuth="false" protocol="TLS" />
</Connector>
-->
<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8009" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="20000"
useURIValidationHack="false"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
<!-- Define an AJP 1.3 Connector on port 8009 -->
<!--
<Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
port="8009" minProcessors="5" maxProcessors="75"
acceptCount="10" debug="0"/>
-->
<!-- Define a Proxied HTTP/1.1 Connector on port 8082 -->
<!-- See proxy documentation for more information about using this. -->
<!--
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8082" minProcessors="5" maxProcessors="75"
enableLookups="true" disableUploadTimeout="true"
acceptCount="100" debug="0" connectionTimeout="20000"
proxyPort="80" useURIValidationHack="false" />
-->
<!-- Define a non-SSL legacy HTTP/1.1 Test Connector on port 8083 -->
<!--
<Connector className="org.apache.catalina.connector.http.HttpConnector"
port="8083" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" />
-->
<!-- Define a non-SSL HTTP/1.0 Test Connector on port 8084 -->
<!--
<Connector className="org.apache.catalina.connector.http10.HttpConnector"
port="8084" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" />
-->
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host). -->
<!-- Define the top level container in our container hierarchy -->
<Engine name="Standalone" defaultHost="localhost" debug="0">
<!-- The request dumper valve dumps useful debugging information about
the request headers and cookies that were received, and the response
headers and cookies that were sent, for all requests received by
this instance of Tomcat. If you care only about requests to a
particular virtual host, or a particular application, nest this
element inside the corresponding <Host> or <Context> entry instead.
For a similar mechanism that is portable to all Servlet 2.3
containers, check out the "RequestDumperFilter" Filter in the
example application (the source for this filter may be found in
"$CATALINA_HOME/webapps/examples/WEB-INF/classes/filters").
Request dumping is disabled by default. Uncomment the following
element to enable it. -->
<!--
<Valve className="org.apache.catalina.valves.RequestDumperValve"/>
-->
<!-- 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 -->
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
debug="0" resourceName="UserDatabase"/>
<!-- Comment out the old realm but leave here for now in case we
need to go back quickly -->
<!--
<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"
connectionName="test" connectionPassword="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:@ntserver:1521:ORCL"
connectionName="scott" connectionPassword="tiger"
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="0" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="/my-jsp" docBase="c:\JSP-Files" debug="0"
privileged="true" reloadable="true" />
<Context path="" docBase="c:\Inetpub\wwwroot" debug="0" privileged="true" />
<Context path="/sharon" docBase="C:\Tomcat 4.1\webapps\sharon" debug="0" privileged="true" />
<!-- Normally, users must authenticate themselves to each web app
individually. Uncomment the following entry if you would like
a user to be authenticated the first time they encounter a
resource protected by a security constraint, and then have that
user identity maintained across all web applications contained
in this virtual host. -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn"
debug="0"/>
-->
<!-- Access log processes all requests for this virtual host. By
default, log files are created in the "logs" directory relative to
$CATALINA_HOME. If you wish, you can specify a different
directory with the "directory" attribute. Specify either a relative
(to $CATALINA_HOME) or absolute path to the desired directory.
-->
<!--
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>
-->
<!-- Logger shared by all Contexts related to this virtual host. By
default (when using FileLogger), log files are created in the "logs"
directory relative to $CATALINA_HOME. If you wish, you can specify
a different directory with the "directory" attribute. Specify either a
relative (to $CATALINA_HOME) or absolute path to the desired
directory.-->
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>
<!-- Define properties for each web application. This is only needed
if you want to set non-default properties, or have web application
document roots in places other than the virtual host's appBase
directory. -->
<!-- Tomcat Root Context -->
<!--
<Context path="" docBase="ROOT" debug="0"/>
-->
<!-- Tomcat Examples Context -->
<Context path="/examples" docBase="examples" debug="0"
reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_DBTest_log." suffix=".txt"
timestamp="true"/>
<Ejb name="ejb/EmplRecord" type="Entity"
home="com.wombat.empl.EmployeeRecordHome"
remote="com.wombat.empl.EmployeeRecord"/>
<!-- If you wanted the examples app to be able to edit the
user database, you would uncomment the following entry.
Of course, you would want to enable security on the
application as well, so this is not done by default!
The database object could be accessed like this:
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
UserDatabase database =
(UserDatabase) envCtx.lookup("userDatabase");
-->
<!--
<ResourceLink name="userDatabase" global="UserDatabase"
type="org.apache.catalina.UserDatabase"/>
-->
<!-- PersistentManager: Uncomment the section below to test Persistent
Sessions.
saveOnRestart: If true, all active sessions will be saved
to the Store when Catalina is shutdown, regardless of
other settings. All Sessions found in the Store will be
loaded on startup. Sessions past their expiration are
ignored in both cases.
maxActiveSessions: If 0 or greater, having too many active
sessions will result in some being swapped out. minIdleSwap
limits this. -1 means unlimited sessions are allowed.
0 means sessions will almost always be swapped out after
use - this will be noticeably slow for your users.
minIdleSwap: Sessions must be idle for at least this long
(in seconds) before they will be swapped out due to
maxActiveSessions. This avoids thrashing when the site is
highly active. -1 or 0 means there is no minimum - sessions
can be swapped out at any time.
maxIdleSwap: Sessions will be swapped out if idle for this
long (in seconds). If minIdleSwap is higher, then it will
override this. This isn't exact: it is checked periodically.
-1 means sessions won't be swapped out for this reason,
although they may be swapped out for maxActiveSessions.
If set to >= 0, guarantees that all sessions found in the
Store will be loaded on startup.
maxIdleBackup: Sessions will be backed up (saved to the Store,
but left in active memory) if idle for this long (in seconds),
and all sessions found in the Store will be loaded on startup.
If set to -1 sessions will not be backed up, 0 means they
should be backed up shortly after being used.
To clear sessions from the Store, set maxActiveSessions, maxIdleSwap,
and minIdleBackup all to -1, saveOnRestart to false, then restart
Catalina.
-->
<!--
<Manager className="org.apache.catalina.session.PersistentManager"
debug="0"
saveOnRestart="true"
maxActiveSessions="-1"
minIdleSwap="-1"
maxIdleSwap="-1"
maxIdleBackup="-1">
<Store className="org.apache.catalina.session.FileStore"/>
</Manager>
-->
<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"/>
<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>
<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
-->
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<!-- MySQL dB username and password for dB connections -->
<parameter>
<name>user</name>
<value>javauser</value>
</parameter>
<parameter>
<name>password</name>
<value>javadude</value>
</parameter>
<!-- Class name for mm.mysql JDBC driver -->
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<!-- The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that the
mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
connection. mysqld by default closes idle connections after 8 hours.
-->
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/javatest?autoReconnect=true</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>
<ResourceLink name="linkToGlobalResource"
global="simpleValue"
type="java.lang.Integer"/>
</Context>
</Host>
</Engine>
</Service>
<!-- The MOD_WEBAPP connector is used to connect Apache 1.3 with Tomcat 4.0
as its servlet container. Please read the README.txt file coming with
the WebApp Module distribution on how to build it.
(Or check out the "jakarta-tomcat-connectors/webapp" CVS repository)
To configure the Apache side, you must ensure that you have the
"ServerName" and "Port" directives defined in "httpd.conf". Then,
lines like these to the bottom of your "httpd.conf" file:
LoadModule webapp_module libexec/mod_webapp.so
WebAppConnection warpConnection warp localhost:8008
WebAppDeploy examples warpConnection /examples/
The next time you restart Apache (after restarting Tomcat, if needed)
the connection will be established, and all applications you make
visible via "WebAppDeploy" directives can be accessed through Apache.
-->
<!-- 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"/>
<Engine className="org.apache.catalina.connector.warp.WarpEngine"
name="Apache" debug="0">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="apache_log." suffix=".txt"
timestamp="true"/>
<Realm className="org.apache.catalina.realm.MemoryRealm" />
</Engine>
</Service>
-->
</Server>
Pleas4 help!!!you have your driver jar in Tomcat\common\lib?
if so, check your classpath, it could be that. -
Session Pooling for CRMoD - Web services.
Hi,
We have a Java application which fetches the Contact Data on the basis of the Phone Number in CRMoD, using web services. (it happens on a hyperlink click).
Before fetching the contact data, we establish the session between our app and CRMoD using the URL - https://<pod>.crmondemand.com/Services/Integration?command=login.
The jsessionId is retrieved and then used for subsequent interaction with the web services.
However, everytime any user clicks on the hyper link...the entire process is executed right form the connection establishment to fetchng the contact data.
This results in a lot of time for the entire process to execute (roughly around 6-7 seconds).
We would like to reduce the time , possibly by implementing a connection pooling for the login.
Can any one suggest how to implement a sesision pool for the JsessionId that is returned from CRMoD ?
Regards,
Bibin.You should definitely move to STATELESS web services for this and not STATEFUL. You also get a bit of scalability also.
If you were to pass the SESSIONID around to multiple processes (or one that was threaded), you might still get RIP (ie, concurrency timeouts) errors. By using the STATELESS approach to web services, you get the built in connection pooling plus an automatic handler for concurrency/queueing.
In the STATELESS, all of your processes just supply the USERID/PASSWORD in the call. CRMOD decides whether an existing POOLed connection is used. You actually have to do less in terms of management this way.
We implemented an external facing web application for a client that used a single USERID/PASSWORD to "confirm" an Appointment that was established via STATELESS connections.
Mychal Manie
Hitachi Consulting - Oracle Practice -
Suitable for big enterprise applications?
Hello,
I am an advocate of Apex in our Oracle Forms shop, but received the following statement: "I am afraid that because of its 2 tier architecture (entire processing is taking place in the DB) it is not suitable for big enterprise applications".
Please help me respond to this.
Not by saying "yes, it is" or "no, it is not, the person is right", but by saying why it is or it is not.
References would be nice too.
Thanks very much, in advance,
GaborAs the Director of IT for my company, here's why we use APEX as our main data entry/reporting solution:
1) Centralized data. All the data resides in a single place. No duplication and no wondering "Is this everything?"
2) Anywhere access. Because it is web/browser based, your users can gain access to the system whether at work or on the road. My company operates in the transportation industry across more than 8 states and we support many traveling managers. Web-based access and wireless connectivity enable them to be anywhere and get access to real-time data.
3) Instant deployment and updates. With APEX, content and new functionality can be instantly deployed across an entire organization without the need for expensive software management agents. It also eliminates versioning problems because it ensures everyone is using the same version. You can't do it that simply with a normal enterprise application.
4) Cross-platform Compatability. Again, because everything is browser-/standards-based, users can use Apple, Windows, Linux, smartphones, etc. Most standard applications have to have specific components written to interact with each type of device or operating system. With web applications, you can develop once and deliver everywhere.
5) Rapid development. I can have a basic application developed including table definitions, etc. in a matter of days BY MYSELF.
About the comment, I'd like to know what types of enterprise applications AREN'T 2-tiered or even 3-tiered applications? You have a presentation layer and a data layer in all applications; the application doesn't house the data itself. The main difference between APEX and many other applications is the delivery method: instead of a proprietary/internal transfer of data between the data layer and the presentation layer, it's being run out over the Internet. Frankly, the concern isn't about the tiers, it's about something else and the objector doesn't want to tell you the real reason. -
Server-side connection pooling for clients in different VM's
We have a need to centeralize our connection pool manger.
Is there a server-side connection pooling manger product to allow multiple clients running in different VM's to connect to and share connection objects to the same Database?
e.g. An applet, and a swing and a servlet/web app application all running in different VM's will connect to this central connection pool manager and share connection objects to the same DB.
We are using connection pooling for all of our applications but each application is maintaining its own connection pool and it is becomming a nightmare to manage and configure each one.
Also, we have to have at a miniumum one connection open per application to access the database regardless of wether we are using connection pool or not. This means that 100 apps(running in different VM's) will use at minimum 100 connections... where all of these 100 apps will do just fine with just 10-15 connections.
while back we used T3 server but can't find this product on BEA web site any more.
does jdbc 2.2 or 3.0 have any server side pool management specs outlined?
Please HELP as we can't afford anymore licensing fees for our company.
oh.. We can't open and close connections on each query as they will be slow.
any suggestions greatly appreciated.if i understand you question, i don't think this is possible, since the Connection interface (and basically all of the related jdbc interfaces) aren't Serializable.. so they can't be sent over the wire to your client(s).
However, you could feasibly write some server side connection pool, and some server side facade which will allow clients to submit queries (either SQL String's or however you want to do it - obviously a more elegant solution involves a series of classes which dynamically create sql based on query criteria), then the server can grab a connection, execute the query, cycle through the results and populate some result object of your creation and send that back over the wire to your client(s).
. -
Replace Quotes, Connection Pooling, and Sun Web Server with MySQL, Oracle
This is code I use to insert data into my MySQL and Oracle databases.
I takes care of quotes and shows use of context, i.e. when you use Sun Web Server's
ConnectionPooling. This code works. Feel free to reply if you have questions on how to set up connection pooling using Sun Web Server 6.1SP - it took quite a long time to learn and I couldn't find much information throughout the web, so I hope this helps...
This is not a question and I am not looking for an answer, but please post comments or suggestions.
dailysun
This is in one class where I have a hashtable containing the
column name / value pairs that I want to enter into my table.
This class simply creates the SQL string from the values in the
hashtable. It then passes that hashtable including the database
name to a class which executes that sql statement (second code
portion).
/* Insert data into sf_parts. Create the column strings from
* the provided hash table. Be sure to parse out hash elements which
* are used for the createTemplate process
StringBuffer values = new StringBuffer();
StringBuffer fields = new StringBuffer();
Enumeration keys = fieldHash.keys();
while(keys.hasMoreElements()){
Object currentKey = keys.nextElement();
String fieldValue = (String) fieldHash.get(currentKey);
if(values.length() >0){
values.append(",");
values.append("'"+fieldValue.replaceAll("'","''")+"'"); // Takes care of quotes and various other special characters!
if(fields.length() >0){
fields.append(",");
fields.append(currentKey);
sql = "INSERT INTO myTable (" + fields.toString() + ") VALUES (" + values.toString() + ");";
String insertResult = caq.getInsertDelete(sql,"myDatabaseName"); // your database name is defined in web.xml and sun-web.xml when you use Sun Web Server's Connection Pooling.
returnValue += "<br><br><b>Rows inserted into table(myTable): </b>" + insertResult + "<br>\n";
And, like I describe above, this method executes the sql statement.
* Takes care of insert, update and delete requests.
* Must have set both dbName as well as the sql String.
* Will return number of rows affected as String.
* @return String Number of rows affected
* @exception SQLException
* @exception Exception
public String getInsertDelete() {
checkData(); // this simply checks if the variables dbName and sql are not empty ;-)
InitialContext initContext = null;
int rv = 0;
try{
// Get connection from configured pool
initContext = new InitialContext();
source = (DataSource) initContext.lookup("java:comp/env/jdbc/" + dbName); // I have this set up in web.xml and sun-web.xml (I use Sun Web Server 6.1SP which does connection pooling for me)
conn = source.getConnection();
if(conn != null){
stmt = conn.createStatement();
rv = stmt.executeUpdate(sql);
}catch (SQLException e){
// do something
}catch (Exception e){
// do something
}finally{
try{
stmt.close();
}catch(Exception e){
// do something
try{
conn.close();
}catch(Exception e){
// do something
try{
initContext.close();
}catch(Exception e){
// do something
return rv+"";
}This is code I use to insert data into my MySQL and
Oracle databases.
I takes care of quotes and shows use of context, i.e.
when you use Sun Web Server's
ConnectionPooling. This code works. Feel free to
reply if you have questions on how to set up
connection pooling using Sun Web Server 6.1SP - it
took quite a long time to learn and I couldn't find
much information throughout the web, so I hope this
helps...
This is not a question and I am not looking for an
answer, but please post comments or suggestions.Using prepared statements would mean that you wouldn't have to worry about quotes.
You should be closing the result set.
You are handling all fields as strings. That won't work with time fields and might not work for numeric fields.
Presumably most of your variables are member variables. They should be local variables because that is the scope of the usage.
You must do something with the exceptions.
Hashtables although convienent mean that problems with usage can only be resolved at run time rather than compile time. -
EP 6.0 SP2 PL28 - connection pool for principal type UACC fails
Hello,
does anybody have the same problem? - We always lose the LDAP-Connection after restart of the j2ee-Services on our Enterprise Portal. We get then this error-message:
->
<b>connection pool for principal type UACC fails</b>
Loading application: com.sap.portal.usermanagement
Loading services:
Loading service: com.sap.portal.license.runtime|license
Jul 2, 2005 4:27:09 AM # System_Thread_32 Fatal [class=com.sap.security.core.persistence.datasource.imp.LDAPConnectionManager][method=initConnectionPool()][cl=13324]connection pool for principal type UACC fails
Thanks in advance.
Regards,
RalfDoes anybody can help me? - It´s important.
Thanks in advance.
Regards,
Ralf -
Setting up connection pool for cloudscape 10 embedded database
I got problem with setting connection pool via admin console for cloudscape 10 embedded in j2ee 1.4 (Application server 8.1), what im doing is:
-in resources/jdbc/ConnectionPools i add a new pool
- datasource classname i set up as: "org.apache.derby.jdbc.EmbeddedXADataSource"
-resource type: "javax.sql.XADataSource"
-DatabaseName: "jdbc:derby:D:\\Programowanie\J2EE\domains\domain1\config\notesData"
-set no password and user, becouse i havet set this in database
and when i ping to that datebase i got error:"Operation 'pingConnectionPool' failed in 'resources' Config Mbean."
when i change Datasource Classname to: "org.apache.derby.jdbc.EmbeddedDataSource", this error occur:
Operation 'pingConnectionPool' failed in 'resources' Config Mbean. Target exception message: Connection object cannot be null
what im doing wrong? i look everywhere and i cant find solution to my problem...hope you can help me.
Thanks,
KrystianAmit wrote:
>
"whats are the settings (URL, driver, properties) required to set up a connection pool for DB2 on OS/390 ?I'm using "COM.ibm.db2.jdbc.app.DB2Driver" as DB2 driverHi. If you can successfully use that driver with one of it's simple
JDBC example programs, then show me that example, at least the
part that makes the connection, and I'll show you how to define a pool.
Joe
PS: Folks: BEA WebLogic is expanding rapidly, with both entry and advanced positions
for people who want to work with Java, XML, SOAP and E-Commerce infrastructure products.
We have jobs at Nashua NH, Liberty Corner NJ, San Francisco and San Jose CA.
Send resumes to [email protected] -
Problem creating a connection pool for mssql server
Hi
i downloaded the microsoft type 4 driver for JDBC and i have installed it. now i am trying to create a connection pool for MS Sql server but each time i ping i keep getting an error telling me
Operation 'pingConnectionPool' failed in 'resources' Config Mbean. Target exception message: Connection could not be allocated because: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket
please can someone help out on this
IfeanyichukwuI assume that you installed the driver correctly. You did go into the app sever admin and set the JVM path? You do this by going to Application Server | JVM Settings | Path Settings and putting in an entry for Classpath Prefix.
If that is done and it's not something basic like your database isn't turned on, then it must be your settings. To to Sun's site and search for dbping. http://developers.sun.com/prodtech/appserver/utilities/dbping/dbping_overview.html
Deploy this program and run it. It is a very simple tool that lets you test different property settings. Play around with different settings until you get a ping.
If that doesn't work post your connect pool settings.
Good luck
Mike -
Configuring the authentication scheme for a web application
Hi all,
We have a requirement to configure the authentication scheme for a web application where some set of users should access the application using basic LDAP (userid/password) authentication and some using digital certificate authentication.
Since the deployment descriptor (web.xml) allows only one directive for auth-method in logic-config, we want to know if there is any other way to achieve this requirement. We are thinking of a custom login module approach. But we are not able to figure out how to configure the auth-method at runtime from the login servlet.
Please let us know if there is any other approach to achieve this.
I will be thankful if any body shares any specific solution to this issue.This forum is probably not the correct one to ask in. It's more related to the web container than Java Programming.
Kaj -
One Search service application for multiple web applications in a single server
We are planning to host 17 Web applications in a single Server. Do I need to create search service application for each web application or I need to create one Search service application , create a Content source for each web
application and create a Result source for filtering. Which is the best approach. And which approach takes more RAM memory.
In my application I am using Search web part, "Recently Changed Items", "Popular Items" web parts. when I created only one one Search Service application for all web applications and using Result sources ,
I am not getting the results. What could be the problem.Hi,
One SSA is ok, but you should think about access rights. If the access is clear cut between all the web apps you should be ok with one SSA. Multiple result sources limiting on content source also works, but could easily be bypassed.
Multiple SSA's will eat up RAM/CPU like a mother :)
As for popular etc.. it could be due to how those sources are set up, but haven't investigated or tested this much.
Thanks,
Mikael
Search Enthusiast - SharePoint MVP/MCT/MCPD - If you find an answer useful, please up-vote it.
http://techmikael.blogspot.com/
Author of Working with FAST Search Server 2010 for SharePoint -
Office Web Apps - how to disable office web apps features for one web application
ENV: Sharepoint 2010 farm with office web apps + fast search
I have the requirement for one web application to open all its documents in client applications - I can enable feature "OpenInClient". This web application uses team site template and other web application also uses team site template. ( feature
stapling ruled out) Now I can run powershell cmdlet to enable this feature on all the currently existing site collections. But the requirement is to enable this feature for all the future site collections. This web applications has 60 k site collections
and atleast more than 10 site collections get created each day and they dont like the option to run a powershell script each day to activate this solution.
Is there any other way to by default activate new site collections on this WA to open in client applications by default (can we disable this office webapps features only on one web app)?
VMI have learnt from this forum that it is not possible to turn off Office web apps on single web application. The line of control lies at farm level and then at site collection.
Disable
Office Web Apps on web application
VM -
Different connection pool for a report
Hi experts,
For one my reports using 'CLOBS' like explained (http://oraclebizint.wordpress.com/2007/11/12/oracle-bi-ee-101332-working-with-clob-fields/) I need to disable parallel processing because it's not supported.
NO_PARALLEL and NO_INDEX_PARALLEL hints at the query level couldn't disable the parallelism.the optimizer still use it.
I thought about having a new connection pool that contains 'before query' and 'after query' statements that will disable the parallelism.This will take me a lot of time to rebuild the whole Presentation and Business layers to point to a new physical tables.
Any one has an idea about how I can use another connection pool for a specific report?
RegardsI have the problem. My issue is that I need to have a webservice use the 2 database connection pools I have created. Originally the pools were Non-XA. When I change them to XA I cannot get the JMS JDBC Store to work.
java.lang.Exception: WebLogic Pool Driver doesn't support XA driver, Please change your config to use a Non-XA driver
However, part of what you wrote below I don't understand. You said you configured a brand new JMS JDBC Store and was able to use an XA Connection Pool? I tried to delete my existing one and create it anew, but was not able to use an XA pool.
Is there any solution around this? I need to have an XA Pool for a webservice but non-XA for my JMS Store.
"After much digging I found documentation that you cannot configure an XA JDBC Connection Pool for use with a JMS JDBC Store: http://edocs.bea.com/wls/docs81/ConsoleHelp/jms_config.html#1128929
The only thing is that if I configure a brand new JMS JDBC Store and make it use the XA JDBC Connection Pool (instead of just selecting the new MySQLXAConnPool from the list that includes the non XA pool) it works without an error." -
Connection Pooling in Core Java Application
I need to implement Connection pooling in core java applications..
My database is MySQL 5.0.27 and java version 1.5.0_09
Any links or ideas will be really appreciatedbut i just wanted to know, how can i do that in core java application. i have used connection pooling in Tomcat using dbcp
but these are my questions.
1. How can i run a core java application doing TCP connection in an Application Server which has got Tomcat and i'm asked to do connection pooling in the Tomcat server.xml.. I didn't understand this requirement pls help me... plssssssssssss
Maybe you are looking for
-
Read from spreedsheet file dont read the file correctly
Hi, i have the problem that i want to show my voltage output (4 channels) on a graph, by saving the data (the saving process is in a SubVI) on the PC and reloading it in the mainVI when all actions are done. If i open the file with a editor, like Ul
-
Has anyone used a Pinnacle TV for Mac HD Stick
Hi, I was looking into this product and was thinking about getting it for my powerbook G4 1.67 Ghz. I know it came out about 2008 and is now discontinued but all new TV viewer programs require an Intel mac. With this one you can use a G4/G5 and Intel
-
Hi, I am embedding the font verdana to a textField. But its not getting worked. Also i have used the linkage to actionscript with the embedding font. The following code i have used for embedding. Can anybody help me by notifying the
-
Ipod update freeze, firewire problem, possible fix for many.
Hello all, I've been having a problem with my ipod 3rd gen updating in much the same way as many in this forum have throughout a number of topic threads. PROBLEM: During song/playlist/content (not software update or restore) updating function one of
-
RAW files automatically modified
Ive noticed in discussion groups below that rotated files in the iPhoto library are automatically copied to a modified folder (perhaps to maintain the history of the photos) - this has elements of the idea of backup "Vault" in Aperture. However what