Tomcat - Automatically Setting up the JDBC connection on deployment
I got sick of setting up the JDBC source in Tomcat after deploying, this is how I overcame it.
1. Create a directory:
{project}/src/web/META-INF
2. Create a file there
{project}/src/web/META-INF/context.xml
Heres is the contents of context.xml
<?xml version='1.0' encoding='utf-8'?>
<Context docBase="/root/jakarta-tomcat/webapps/toll" path="/toll" workDir="work/Catalina/localhost/toll">
<Resource auth="Container" description="Rave generated DataSource Reference" name="jdbc/transact" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/transact">
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>200</value>
</parameter>
<parameter>
<name>password</name>
<value>dummypass</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/transact?autoReconnect=true</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>50</value>
</parameter>
<parameter>
<name>username</name>
<value>dummyuser</value>
</parameter>
</ResourceParams>
</Context>Hope this helps someone.
Regards
Jonathan
Also add this in there for Tomcat .. we are using Tomcat 5 so check for other versions.
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>removeAbandonedTimeout</name>
<value>1200</value>
</parameter>It turns on Tomcats connection recovery, so if your application has a connection leak and doesn't shut them all down. Tomcat will shut down unused connections, it uses the timeout value to determine which are unused. (1200 secs - 20 mins)
Regards
Jonathan
Similar Messages
-
Lot of cursors hanging even the jdbc connection are closed
We use tomcat and thin oracle driver for out application. But we found lot of cursors hanging even the jdbc connection are closed.
We use a connection pool to manage the connections.after properly closing the connections ,try to set all the Connection objects and ResulSet objects to null (force to null) , most likely these inactive sessions will dissapear.
might be a java garbage collection issue?
anyhow. I managed to get most of these inactive sessions to disappear. although I am using a Servlet. some of them are still not closed
Regards -
How can I sync the calendar and contacts from my icloud account to the new icloud account we set for my husband on his iPad and iPhone 5S? I have already set up the Family connections but they are not syncing.
Thanks.
JennyOops my bad...I see that during my troubleshooting I inadvertently left Ringtones unchecked in iTunes.
-
Advanced Queue - using the JDBC connection
Advanced Queue using the JDBC connection gives us AN ERROR WHEN SENDING 32K QUEUES
Is it true that RAW datatypes using the Java AQ API do indeed have a limit of 32K in 8.1.6.
The workaround is to use the Java AQ API with Object payloads (BLOBs) to get around the problem.
Has anyone used any other solution ?
Thanks
nullThere's a JDBC forum that's probably more germane to this question-- I'd suggest reposting it there.
Justin Cave
ODBC Development -
How to set roles from JDBC connections
Hi guys,
I have a jdbc connection which purpose is to run queries based on a string that I construct in my program.
My question is: if I have to run a DCL, like: SET ROLE RL_XXX TO USER1;
What's the easiest way to do it with my same connection?
Thanks.Hi Marc,
Sorry for the typo. It's a BDC source, I use a WCF client to access a SQL Database (HR External System) that has 4 fields that are necessary to present in the Sharepoint User Profile. The issue occurs with a Full or a Delta Sync. The problem is that if the
BDC source is not present the fields are deleted (I get a SPS-Dummy Added and all of the pbjects in the BDC Connector Space are deleted).
I do not want this to happen. I do not want the User Profile Attributes/Fields to be empty/deleted if there is no connection I simply want them to stay what they are... I have two issues.
1) Is that the even if i change my data on SQL Server side, the changes do not get picked up by the sync. Since the only field that is being tested for change is an ADid, since the id does not change the BDC does not consider them changes.
2) If there is no connection I do not want the attributes to be deleted. I have not figured out a way to effectively do this.
So my issue appears to be simple to solve, but after 4 days and hundreds of tutorial pages read I have yet to figure out a proper way to do this.
Here is the pseudo-specification
The Fields that come form the HR System (SQL Server) are to be presented in the user profile. If there is no connection to the BDC file the fields remain as they are until there is a connection and updates can be made. Changes to any of the fields are performed
manually in the HR system. These changes must be picked up by the daily sync. -
Setting-up the Internet Connection
Hi All, my systems has the following Linksys products:
modem - ADSL2MUE
wireless router 1 - WRT54GS (1st floor)
wireless router 2 - WRT54G (2nd floor)
switch - SR2024 (for cable connections)
I was able to connect all the PC to the internet. My problem is I could not make all the PC be in same Gateway number in which I could not share the network printers and files to all PCs. Is there any way to solve this problem? Below are settings to each device:
ADSL2MUE - Bridge Mode only
WRT54G - IP Address (192.168.1.1), PPPoE
WRT54GS - IP Adress (192.168.2.1), DHCP
* ADSL2MUE Internet Port is connected to WRT54G Internet port
* WRT54G Ethernet Port 1 is connected to SR2024 Ethernet Port
* WRT54GS Internet Port is connected to SR2024 Ethernet Port
* Printer 1 is connected to SR2024 Ethernet port (2nd floor)
* Printer 2 is connected to WRT54GS Ethernet Port (1st floor)
* All PCs in the 1st floor is using 192.168.2.1 gateway number thru WRT54GS wireless connection.
* All PCs in the 2nd floor is using 192.168.1.1 gateway number thru WRT54G and SR2024.
I need your help on this.
Best rgds, jovenIt does not matter how you set the internet connection type on the second router when nothing connects to the internet port. The internet connection type is used for the configure of the connection through the internet port. As nothing is connected in the internet port the setting is basically inoperable and makes no difference whatever you set there. You should not set a static IP address as that may affect the routing tables on the router even if the internet interface is down. Thus, just leave it on Automatic/DHCP and it should be fine.
-
Deployed application can't see the JDBC connection
Hi
I made an ADF application using oracle JDeveloper 11g and it ran successfully from the JDeveloper
I deployed it to Weblogic 10.3 and it successfully deployed
But when i Opened the deployed application's URL the page's lay out is only what i c (only the template) with the following error:
=================================================
Error while opening JDBC connection.
ORA-01005: null password given; logon denied
Unexpected exception caught: java.lang.NullPointerException, msg=null
=================================================
SO, how could I make my application c the JDBC ?
by the way when i created the DB connection in the JDeveloper i checked(deploy password)Hi Eddy
I got the same problemas you posted.now i changed the configurations of AMlocal.i changed from JDBC URL to JDBC datasource.
i saved the changes. i created a new EAR and deployed to external WLS 10.3 from Jdev11.1.1
when i am testing tha app from external WLS,i am getting the following error
JNDI failure.unable to lookup DataSource at context
java:comp/env/jdbc/Connection1DS
while trying to lookup'jdbc.Connectiobb1DS' didn't find
subcontext 'jdbc'.Resolved"
Unexpected exception caught:
java.lang.NullpointerException,msg=null
Can you tell me where the problem is? -
Trouble with setting up the network connection
I am having trouble with setting up my network connection on my new laptop, we use a telecom xtra broadband connection for our windows computers in the house. But when i try to put what i think is the right information in the set up it comes up with "network connection could not be configured"
Hi,
you can not connected to sap on 127.0.0.1 ip address it is loopback address for local host.
instead of give the ip address where sap is running.
if you running SAP on your standalone PC/laptop then you need to assign one ip address to that host
use this ip address to connect.
regards,
kaushal -
Setting Up the SLD Connection for WebDynpro Flight List
I have to set the "cim client generation settings" in the visual admin. But what host? J2EE Engine, R/3 backend, something else? An example would be helpfull.
HI to everyone,
I have the same problem...
...the <b>configuration of SLD is really a pain</b>...
My WAS 6.40 J2ee only java is named pedroxp an runs on 50000.
I have done these steps:
1)In <b>Visual Admin</b> I have set all the property of the famous <b>SLD Data Supply</b> with these values
<b>HTTP Settings</b>
host: pedroxp
port: 50000
user: Administrator
The same values are in the <b>CIM Client generation Setting</b>
and in the <b>RFC Settings</b> I have
Gateway Host: localhost
Gateway Port: sapgw00
When I test the Button <b>CIMClient Test</b> I have <b>success</b> !
2) I connect to my ... <b>SLD</b>
<b>http://pedroxp:5000/sld</b>
Here I have defined a <b>Technical System Type</b> --> <b>Web as java</b>
I have added a JCO Destination --> OK
I don't know what to do in order to add a <b>Message Server</b>
I have also added info in Data Supplier Bridge Administration...
3) I go to WebDynpro console
http://pedroxp:50000/webdynpro/dispatcher/sap.com/tcwdtools/Explorer
but when I try to create a new JCO Destination,
I go trugth all the 6 steps ... some doubt about the Message Server or Saprouter selection in step 4.2.
When I click finish I have an Error ...
An Error quit difficult to read because is just one row long a kilometer...
<b>Who is so kind to bring the light in this mess ?</b>
I have read a lot of documentation,
but I can't figure it out alone...
Thanks in advance -
Tomcat 5.5.20 / Oracle JDBC connection error
Hi All,
I am using Eclipse 3.2/ Tomcat 5.5.20/ Oracle 8i
Inside my java class; right after finding the context, it gives error on line:
conn = dataSource.getConnection();
my server.xml <Resource> settings are proper within one tag...
I am loosing my hair faster... please someone help me..
Error Stack:
javax.servlet.ServletException
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NullPointerException
com.nibtt.beans.ConnectionBean.getConnection(ConnectionBean.java:80)
com.nibtt.actions.LoginAction.execute(LoginAction.java:44)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Regards
HepziHi Zadok,
I am going insane. Thank God you replied. I am pasting my code here.
I have setup Tomcat5.5.20 <resource> tag as follows: for connection pooling
<Resource name="jdbc/TestStrutsDB" auth="Container"
type="javax.sql.DataSource" factory="org.apache.commons.dbcp.BasicDataSourceFactory"
username="SCOTT" password="TIGER"
driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@111.1.1.1:1521:TEST"
maxActive="8" maxIdle="4"/>
my application web.xml code:
<resource-ref>
<description>Oracle DB Connection</description>
<res-ref-name>jdbc/TestStrutsDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
my java code:
public Connection getConnection() throws Exception{
Context ctx = new InitialContext();
Context envContext = (Context)ctx.lookup("java:/comp/env");
javax.sql.DataSource dataSource = null;
ResultSet rst = null;
Statement stmt = null;
try {
if(envContext == null ) {
System.out.println( "context is NULL");
} else
System.out.println( "context is NOT NULL");
dataSource = (javax.sql.DataSource)envContext.lookup("jdbc/TestStrutsDB");
if (dataSource != null) {
System.out.println( "before actual connection to database: "+dataSource.toString() );
try {
conn = dataSource.getConnection();
} catch (Exception connEx) {
System.out.println( connEx.getStackTrace());
if(conn != null) {
System.out.println( "Got Connection "+conn.toString());
stmt=conn.createStatement();
rst=stmt.executeQuery("select username from testTomcat");
while(rst.next()){
System.out.println("User Name is: " + rst.getString("username"));
rst.close();
rst = null;
stmt.close();
stmt = null;
conn.close();
conn = null;
// do what you wish with Connection
} catch (SQLException e) {
while((e = e.getNextException()) != null) {
System.out.println("SQLException: " + e.getMessage());
System.out.println("SQLState: " + e.getSQLState());
System.out.println("VendorError: " + e.getErrorCode());
System.out.println(e.getStackTrace());
} finally {
try {
conn.close();
} catch (SQLException ex) {
System.out.println(ex.getStackTrace());
return conn;
} //End of Connection function
Please let me know if had gone wrong somewhere
Thanks in advance
Regards
Hepzi -
How to increase the JDBC connections peroformacnce
Hi Iam new to Weblogic admin
We are using weblogic 10. in solaries + oracle database env
We are facing the slowness issue for internet application users, after submitting the user name and password, user will not get any response from the application except blank page,
I have observed that there are somany; more than 200 Waiting For Connection Total. This will increase in peak time.
wii this is the cause for the issue or if any other.
Please suggest us to resolve the issue.
Edited by: user11103866 on May 8, 2009 2:12 AMmore than 200 Waiting For Connection Total.<<This is from a JDBC pool? If so, then you have more users than your pool can handle.
How many initial / maximum connections does this particular pool allow, and how many servers are within your cluster?
What is your applicaiton's session timeout value?
Ask your DBA how many connections the database currently allows.
You can also configure the shrink period of the pool if your user sessions are short, or if your users are not logging out ( which results in their session holding a connection until the session times out ).
Are you seeing Leaked Connections ( you can configure the console to report these )? -
Our connection pool looses connection to oracle(ORA-03114) in a random manner.
We use jdk1.2, jdbc 8.1.6 drivers & oracle 8.0.5 db on solaris 2.6.
This problem started when we switched from jdk1.1.7, jdbc 8.0.5.2.
We also seem to have problems reading from a date column, rs.getString("DATECOLUMNNAME") has for some reason seized to work.
The application is pretty db exhausting, we use a lot of long raw fields for storing images etc.
The connection pool is a free version from Bitmechnic.You probably want to ask this question in the SQLJ/JDBC forum, or with Bitmechnic. ODBC is a similair protocol to JDBC, but they're completely separate products.
Justin Cave
ODBC Development -
How can I appoint a kind of charset to the jdbc connection.
The database charset is US7ASII,and I want to get it as charset GB2312.What should I do?
As I know in other JDBC,we can set property of 'charset' when we use getConnection,but it seem not with oracle jdbc.Is there an other way?Is there anyone know it?
-
Access to the jdbc connection list
Hi, I'm devolping a plugin for the Sap Developer Studio, It's a wizard that generate the EJB code from a database table. Any body knows how to access to the list of JDBC resources (defined in Visual Administrator) vía java code?, is there any way to make a new entry by code?
ThanksCheck out the author page for Venkatesh, there are few blogs written by him on retriving app server resources list / modifying them. May be you will get hint regarding how to go about your req.
/people/venkatesh.ramachandran/blog -
Changing the Database connection after deployment.
Dear All,
I have deployed an application and want to change the connection to live database so how do i change it..
Do i have to redeploy the application ?. Both db's are oracle.
-ThanksHi Santosh,
As Frank said u can connect ur Application using a JDBC Datasource.. So u can change in ur Connection Settings in WLS... u can find the documentation as below....
Section 9.3.1 http://download.oracle.com/docs/cd/E14571_01/web.1111/b31974/bcservices.htm#sm0203
For Weblogic Server : Section 35.8 http://download.oracle.com/docs/cd/E12839_01/web.1111/b31974/deployment_topics.htm#CHDFJADJ
Regards,
Suganth.G
Maybe you are looking for
-
Firefox plugin breaks after Bluetooth audio switching
Tracked down a bug to the FF flash plugin: On XP sp2 using FF 2.0.0.12 and Flash 9.0.47.0 (rolled back from the 9.0.115.0 disaster) after starting then stopping a Bluetooth audio session (a2dp), Flash no longer plays audio/video. All the usual sites
-
Shell script for cpu governor toggling [SOLVED]
I am fairly new to shell (bash) scripting, but i thought i would at least manage an if test, though i was proven wrong :/ I have been looking at this for way to long by now, and i am positive i am just missing the obvious, though I just cannot see wh
-
I am trying to add Adobe Acrobat Pro to my existing Illustrator Subscription.
It tells me to contact support to see if I am eligible for an upgrade before I can buy anything. But only support offered is this forum. Great job Adobe - get some sales people!
-
Crystal Reports Server 2008 Installation Error
Good day, My name is Dominic Hung and I work at Business Objects. One of my clients is coming across an installation error on their evaluation of CRS 2008 and is detailed as follows: They currently have the actual report writer (Crystal Reports 2008
-
How can i get the extended warrnty for my apple ipad 3..in india ..
is it realy required..? kindely sujest..