Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
DB Connection prob

DB Connection prob

2007-03-20       - By Graeme McLaren

 Back
Reply:     1     2     3     4     5  

Hi there Richard, thank you for your reply.  I'll give the final keyword a
go.  With respect to:

>If this is so, your application is not going to be thread-safe b/c the
>connection is static and can be used by different threads. If this is for a
>web application, you should use a connection pool and a datasource

I have been doing a java course and this is my first web app outwith the
course material (thread safe connections have never been mentioned in the
course).  I don't know anything about connection pools/datasources where can
I find a good tutorial or good newbie info on this?

What problems will be be caused by using the non thread safe connection as
it is at the moment?  I'm thinking performance problems.


Thank you again for your reply.

Graeme :)


>From: Richard Yee <ryee@(protected)>
>Reply-To: A mailing list about Java Server Pages specification and
>reference <JSP-INTEREST@(protected)>
>To: JSP-INTEREST@(protected)
>Subject: Re: DB Connection prob
>Date: Mon, 19 Mar 2007 21:44:14 -0700
>MIME-Version: 1.0
>Received: from swjscmail2.java.sun.com ([192.18.99.108]) by
>bay0-mc3-f9.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668); Mon, 19
>Mar 2007 21:44:13 -0700
>Received: from swjscmail1 (swjscmail1.Sun.COM [192.18.99.107])by
>swjscmail2.java.sun.com (Postfix) with ESMTPid 197BF219EE; Mon, 19 Mar 2007
>22:40:58 -0600 (MDT)
>Received: from JAVA.SUN.COM by JAVA.SUN.COM (LISTSERV-TCP/IP release 1.8e)
>with          spool id 14080077 for JSP-INTEREST@(protected); Mon, 19 Mar
>2007          22:38:12 -0600
>Received: from mail.cruzio.com (mail.cruzio.com [63.249.95.37]) by
>swjscmail1.java.sun.com (Postfix) with ESMTP id 645C6554F for
><JSP-INTEREST@(protected)>; Mon, 19 Mar 2007 22:38:09 -0600 (MDT)
>Received: from [192.168.0.103] (dsl-63 (See http://dsl-63.ora-code.com)-249-97-217.cruzio.com
>[63.249.97.217])          by mail.cruzio.com with ESMTP id l2K4i4um015259
>for          <JSP-INTEREST@(protected)>; Mon, 19 Mar 2007 21:44:04 -0700
>(PDT)
>X-Message-Info:
>txF49lGdW42b/sTindn8aktBOU0PkxWOZO3VQQBd2PraXRfcuczAxtZNUN2UNjMx
>X-Original-To: JSP-INTEREST@(protected)
>Delivered-To: JSP-INTEREST@(protected)
>User-Agent: Thunderbird 1.4 (Windows/20050908)
>References: <BAY138-F2518630EA6FED203237B34D7760@(protected)>
>X-Spam-Status: No,               score=0.0 required=1.0 tests=AWL
>autolearn=disabled version=3.1.7
>X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on mail.cruzio.com
>Precedence: list
>Return-Path: owner-jsp-interest@(protected)
>X-OriginalArrivalTime: 20 Mar 2007 04:44:14.0634 (UTC)
>FILETIME=[694320A0:01C76AAA]
>
>Graeme,
>Since you mention that you are using a deployment descriptor, I am
>assuming this is for a web application. If this is so, your application
>is not going to be thread-safe b/c the connection is static and can be
>used by different threads. If this is for a web application, you should
>use a connection pool and a datasource. In your current problem, your
>variables should not be final.
>
>-Richard
>
>Graeme McLaren wrote:
>>Hi all, I have a prob connecting to my Oracle DB.  I have a class called
>>"DBConnection" and have various setter methods which set values found
>>in the
>>deployment descriptor, for example:
>>
>>  public static void setDriver (String val) {
>>       driver = val;
>>         System.out.println("driver 2= "+driver);  // I get the value
>>displayed here so all is good at this point
>>}
>>
>>I then have a getConnection method within this class:
>>
>>public static Connection getConnection(){
>>    try{
>>      Class.forName( driver ); // load the JDBC "driver" class
>>      connection = DriverManager.getConnection( dbURL, username,
>>password );
>>// get connection
>>
>>        /*
>>                more code here
>>        */
>>
>>} // end of getConnection
>>
>>
>>
>>When I try to call getConnection() I get a nullpointerexception at
>>Class.forName( driver ); as "driver" is set to null, why is this when the
>>setter method sets the value?
>>
>>All variables are declared set to null and are static so they should
>>be able
>>to be set by the setter method shouldn't they?  Just thinking about it
>>now
>>I'm thinking that when the variables are initialised to "null" that is
>>them
>>set and cannot be changed because they are static (and final), would
>>that be
>>right?
>>
>>How should I fix this?
>>
>>
>>Cheers
>>
>>Graeme :)
>>
>>===========================================================================
>>
>>To unsubscribe: mailto listserv@(protected) with body: "signoff
>>JSP-INTEREST".
>>For digest: mailto listserv@(protected) with body: "set JSP-INTEREST
>>DIGEST".
>>
>>Some relevant archives, FAQs and Forums on JSPs can be found at:
>>
>>http://java.sun.com/products/jsp
>>http://archives.java.sun.com/jsp-interest.html
>>http://forums.java.sun.com
>>http://www.jspinsider.com
>>
>>
>
>===========================================================================
>To unsubscribe: mailto listserv@(protected) with body: "signoff
>JSP-INTEREST".
>For digest: mailto listserv@(protected) with body: "set JSP-INTEREST
>DIGEST".
>
>Some relevant archives, FAQs and Forums on JSPs can be found at:
>
>http://java.sun.com/products/jsp
>http://archives.java.sun.com/jsp-interest.html
>http://forums.java.sun.com
>http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto listserv@(protected) with body: "signoff JSP-INTEREST".
For digest: mailto listserv@(protected) with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

http://java.sun.com/products/jsp
http://archives.java.sun.com/jsp-interest.html
http://forums.java.sun.com
http://www.jspinsider.com

©2008 junlu.com - Jax Systems, LLC, U.S.A.