You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by ganesan malairaja <ss...@hotmail.com> on 2005/07/22 04:53:14 UTC

jsp stuff

hi guys

i want to know is there any setting to be done with tomcat so the JSP codes 
can access the database ( MySQL) and display the information ?


thank you



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: jsp stuff

Posted by Phuoc Diec <ph...@gmail.com>.
Hi,

One way to access database from JSP pages is using connection pool
from JNDI. You can find more information from here:
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html


On 7/21/05, ganesan malairaja <ss...@hotmail.com> wrote:
> hi guys
> 
> i want to know is there any setting to be done with tomcat so the JSP codes
> can access the database ( MySQL) and display the information ?
> 
> 
> thank you
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


cvs ant build problem

Posted by David Shapiro <ds...@nc.rr.com>.
Hello,

I am trying to run cvs, but it is failing.  

checkout.depends:
      [cvs] cvs [checkout aborted]: connect to
cvs.apache.org(209.237.227.194):2401 failed: Connection timed out

If you try and ping this site it is not reachable.  Is this not available
anymore?




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: jsp stuff

Posted by beetle <be...@caribserve.net>.
Thankyou very much for your info,best regards,Gregory
----- Original Message ----- 
From: "ganesan malairaja" <ss...@hotmail.com>
To: <to...@jakarta.apache.org>
Sent: Saturday, July 23, 2005 2:17 AM
Subject: RE: jsp stuff


> thanks
>
>>From: Adile Abbadi <ad...@minitdrugs.com>
>>Reply-To: "Tomcat Users List" <to...@jakarta.apache.org>
>>To: Tomcat Users List <to...@jakarta.apache.org>
>>Subject: RE: jsp stuff
>>Date: Fri, 22 Jul 2005 11:12:16 -0600
>>
>>You don't need to change anything in tomcat to make it access a database
>>except one thing - you need is a compliant JDBC driver which you through
>>into the Common Library directory of tomcat. Once tomcat starts it will 
>>load
>>the driver and then at that point you can use code to access the Database. 
>>I
>>would recommend you use a pooling tool as well - to pool your connections
>>and limit resource use.
>>
>>Check google - lots of info out there.
>>
>>HTH
>>
>>Adile
>>
>>
>>-----Original Message-----
>>From: ganesan malairaja [mailto:ssganesan@hotmail.com]
>>Sent: July 21, 2005 8:53 PM
>>To: tomcat-user@jakarta.apache.org
>>Subject: jsp stuff
>>
>>
>>hi guys
>>
>>i want to know is there any setting to be done with tomcat so the JSP 
>>codes
>>can access the database ( MySQL) and display the information ?
>>
>>
>>thank you
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>>--
>>No virus found in this incoming message.
>>Checked by AVG Anti-Virus.
>>Version: 7.0.323 / Virus Database: 267.9.2/54 - Release Date: 7/21/05
>>
>>--
>>No virus found in this outgoing message.
>>Checked by AVG Anti-Virus.
>>Version: 7.0.338 / Virus Database: 267.9.2/55 - Release Date: 7/21/05
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>
>
> Ganesan_Malairaja
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: close pooled conection-by value or by reference

Posted by Bertrand Renuart <be...@itma.lu>.
If you want to make sure the connection is closed/release in any case, put
the close() call inside a finally clause:


  Connection connection = DatabaseManager.getConnection();
  try {
     ....//jdbc work.
  }
  finally {
    DatabaseManager.closeConnection(connection);
  }

This way, whatever happens inside the try block, you are sure
closeConnection will be called (think about an exception being thrown in
the try block...)


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: close pooled conection-by value or by reference

Posted by Philip Cote <co...@adelphia.net>.
connection.isClosed() should return a boolean telling you whether or not
the connection was released.

On Sat, 2005-07-23 at 14:18 -0700, Tony Smith wrote:
> I think this is a classic java question: Pass by
> reference or by value. I have a DatabaseManager class
> which takes care of get conection from connection pool
> and release the connectoin. I am not sure about the
> release part. Here is my code:
> 
> class MyMainClass
> 
> public static final void main(String[] args){
> 
>     Connection connection =
> DatabaseManager.getConnection();
> 
>     ....//jdbc work.
> 
>    DatabaseManager.closeConnection(connection);
> ...
> }
> 
> 
> public class DatabaseManager {
>  
>     public static Connection getConnection(){
>         Connection connection =
> getConectionFromDataSource();
> 
>        return connection;
>     }
>     
>     public static void closeConnection(Connection
> conn){
>     	if (conn != null){
>     		try{
>     			conn.close();
>     		}catch(SQLException sqle){
>     			sqle.printStackTrace();
>     		}
>     	}
>     	conn = null;
>     }}
> 
> 
> I am not sure if the connection is released....
> 
> 
> Thanks,
> 
> 
> 
> 
> 		
> ____________________________________________________
> Start your day with Yahoo! - make it your home page 
> http://www.yahoo.com/r/hs 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


SV: close pooled conection-by value or by reference

Posted by Øyvind Johansen <oy...@electrictimecar.com>.
This isnt really related to Tomcat, but I really don't care:

You could make the connection static in the class DatabaseManager, so that
your application only uses one connection against DB. This could (?) cause
problems with Threading and several users accessing at once (I guess...).
Really not sure about this though...

However, to be 100% sure that the connection is closed and the Connection
object is destroyed by the garbage-collector, you should add connection =
null in the class MyMainClass as well, otherwise this class would hold a
copy of this object until your program terminates...

You should consider using a layered approach to programming. 
Create a class, DataIO (reading and writing) that has abstract methods for
retrieving data and updating them etc.
Create classes for your data, which act as dataholders. I.e. create a class
MyMainClassData that holds the data retrieved in MyMainClass by the
database. Then create abstract methods for retrieving and manipulating the
data in this object. 

Finally you implement these methods in yet another class, DatabaseDataIO
that implements your interface against the database. 

The solution would look something like this:

MyMainClass:
public static final void main(String[] args) {
   New MyMainClass().doTheStuff(neededArgs);
}

Public void doTheStuff() {
	DatabaseDataIO ddio = new DatbaseDataIO();
	MyMainClassData data = ddio.getData();

	... manipulate data

	Ddio.saveData(data);
}

DataIO:
Public abstract MyMainClassData getData();
Public abstract void saveData(MyMainClassData data);

DatabaseDataIO:
Extend and Implement the methods of DataIO

MyMainClassData:
Private fields for every data needed. 
Get and set methods for manipulating the data


In this case you could, of course, still use DataBaseManager, but with or
without it, when you find yourself creating the Main-class, you don't have
to worry about whether or not the connection is being closed. You can trust
that the DatabaseDataIO class does this for you. 

Hope my late Saturday night writing is understandable.

Öyvind Johansen
ETC ElectricTimeCar

-----Opprinnelig melding-----
Fra: Tony Smith [mailto:quickcur@yahoo.com] 
Sendt: 23. juli 2005 23:19
Til: Tomcat Users List
Emne: close pooled conection-by value or by reference

I think this is a classic java question: Pass by
reference or by value. I have a DatabaseManager class
which takes care of get conection from connection pool
and release the connectoin. I am not sure about the
release part. Here is my code:

class MyMainClass

public static final void main(String[] args){

    Connection connection =
DatabaseManager.getConnection();

    ....//jdbc work.

   DatabaseManager.closeConnection(connection);
...
}


public class DatabaseManager {
 
    public static Connection getConnection(){
        Connection connection =
getConectionFromDataSource();

       return connection;
    }
    
    public static void closeConnection(Connection
conn){
    	if (conn != null){
    		try{
    			conn.close();
    		}catch(SQLException sqle){
    			sqle.printStackTrace();
    		}
    	}
    	conn = null;
    }}


I am not sure if the connection is released....


Thanks,




		
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


close pooled conection-by value or by reference

Posted by Tony Smith <qu...@yahoo.com>.
I think this is a classic java question: Pass by
reference or by value. I have a DatabaseManager class
which takes care of get conection from connection pool
and release the connectoin. I am not sure about the
release part. Here is my code:

class MyMainClass

public static final void main(String[] args){

    Connection connection =
DatabaseManager.getConnection();

    ....//jdbc work.

   DatabaseManager.closeConnection(connection);
...
}


public class DatabaseManager {
 
    public static Connection getConnection(){
        Connection connection =
getConectionFromDataSource();

       return connection;
    }
    
    public static void closeConnection(Connection
conn){
    	if (conn != null){
    		try{
    			conn.close();
    		}catch(SQLException sqle){
    			sqle.printStackTrace();
    		}
    	}
    	conn = null;
    }}


I am not sure if the connection is released....


Thanks,




		
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


compiling

Posted by ganesan malairaja <ss...@hotmail.com>.
if i add new jsp file to the a folder in webapps

will it be compiled when i access it  or i must compile it before accessing 
it ..

thankx



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: jsp stuff

Posted by ganesan malairaja <ss...@hotmail.com>.
thanks

>From: Adile Abbadi <ad...@minitdrugs.com>
>Reply-To: "Tomcat Users List" <to...@jakarta.apache.org>
>To: Tomcat Users List <to...@jakarta.apache.org>
>Subject: RE: jsp stuff
>Date: Fri, 22 Jul 2005 11:12:16 -0600
>
>You don't need to change anything in tomcat to make it access a database
>except one thing - you need is a compliant JDBC driver which you through
>into the Common Library directory of tomcat. Once tomcat starts it will 
>load
>the driver and then at that point you can use code to access the Database. 
>I
>would recommend you use a pooling tool as well - to pool your connections
>and limit resource use.
>
>Check google - lots of info out there.
>
>HTH
>
>Adile
>
>
>-----Original Message-----
>From: ganesan malairaja [mailto:ssganesan@hotmail.com]
>Sent: July 21, 2005 8:53 PM
>To: tomcat-user@jakarta.apache.org
>Subject: jsp stuff
>
>
>hi guys
>
>i want to know is there any setting to be done with tomcat so the JSP codes
>can access the database ( MySQL) and display the information ?
>
>
>thank you
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>--
>No virus found in this incoming message.
>Checked by AVG Anti-Virus.
>Version: 7.0.323 / Virus Database: 267.9.2/54 - Release Date: 7/21/05
>
>--
>No virus found in this outgoing message.
>Checked by AVG Anti-Virus.
>Version: 7.0.338 / Virus Database: 267.9.2/55 - Release Date: 7/21/05
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>


Ganesan_Malairaja



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: jsp stuff

Posted by Adile Abbadi <ad...@minitdrugs.com>.
You don't need to change anything in tomcat to make it access a database
except one thing - you need is a compliant JDBC driver which you through
into the Common Library directory of tomcat. Once tomcat starts it will load
the driver and then at that point you can use code to access the Database. I
would recommend you use a pooling tool as well - to pool your connections
and limit resource use.

Check google - lots of info out there.

HTH

Adile


-----Original Message-----
From: ganesan malairaja [mailto:ssganesan@hotmail.com]
Sent: July 21, 2005 8:53 PM
To: tomcat-user@jakarta.apache.org
Subject: jsp stuff


hi guys

i want to know is there any setting to be done with tomcat so the JSP codes
can access the database ( MySQL) and display the information ?


thank you



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.9.2/54 - Release Date: 7/21/05

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.2/55 - Release Date: 7/21/05


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org