Re: web application - student need help Thank You's
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Mike, Michael Ni wrote: So during login, after a person enters his username and password, it will check to see if the username exists in the person table. If it does exist, it will verify the password and return his permission. That permission is stored in the session, and each jsp page it will check to see if his permission is correct. If a person's permission is wrong, it will redirect you to another page. Although this method works, I dont know if it is very professional. Does anyone have any ideas how to set up a professional style authentication system? Something a business would use where exposing customer information is a liability. There's no reason not to use a pre-built authentication and authorization system. For instance, the J2EE container-managed AA is relatively good, if not very extensible. I manage software development for a healthcare service where information security is a top priority. I recently switched from using container-managed AA to securityfilter (http://securityfilter.sourceforge.net), which is intended to be a drop-in replacement for container-managed AA. The syntax is the same for security-constraint, web-resource-collection, auth-constraint, etc. so you can pretty much just move your existing configuration from web.xml into another config file for use with securityfilter. Since the AA is now outside of the container, you can comfortably extend the classes or replace the authenticator to suit your needs. For instance, I wanted to be able to log failed logins to my database. With the container-managed authentication, that was not possible without extending one of Tomcat's authenticators or resorting to other nasty hacks. With securityfilter, I was able to write my own basic authenticator (i.e. SELECT FROM user WHERE username=? AND password_hash=?) and then log failures to the database using the same db connection. With container-managed AA and projects like securityfilter out there, there's no reason to write your own authentication or authorization code, unless you are really doing something exotic. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFo7tH9CaO5/Lv0PARAmzYAKCSC3YN6TipbVUhki3aOfN62kDYTgCgmfZG VLd3kXoPQjd0nQTAoQDajFQ= =mSO9 -END PGP SIGNATURE- - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: web application - student need help
Tracy Nelson. Out of curiosity, can you point to some articles relating to the growing pains you mentioned regarding Slashdot, Granddaddy and MySpace? Thanks Scott Ross -Original Message- From: Nelson, Tracy M. [mailto:[EMAIL PROTECTED] Sent: Monday, January 08, 2007 11:01 AM To: Tomcat Users List Subject: RE: web application - student need help | From: Michael Ni [mailto:[EMAIL PROTECTED] | Sent: Friday, 05 January, 2007 16:38 | | even with connection pooling, how many connections are we looking at here? | if my project works as intended, im predicting from 30 to 1000 poeple | simultaneously hitting tomcat and sql server. If you're just on a cable modem, I wouldn't worry about it. Your network bandwidth will give our before your connection limit. | i remember when websites like friendster.com came out, it was really slow. | now it is much faster, do you guys know where does a student learn | about how to handle high traffic web applications? is there any | classes? Your best bet is to read up on other site that had growing pains (MySpace, Flickr or the granddaddy, Slashdot) and find out what they did. For the most part, you'll have to find a service provider that has the pipes you need for a price you can afford. Then worry about partitioning your set-up: break it up into web servers, app servers (Tomcat), and database servers. Try to split your app into static and dynamic pieces, that'll (theoretically) let you cache static content (icons, logos, boilerplate text) on the web server, which will help your response time. If your database needs are simple (90% reads, most reads from a single table) consider going with MySQL. It's proven itself many times over in high-traffic sites. If you have any kind of real database needs, though (transactions, complex joins, multiple concurrent updates) you'd be better off sticking with SQL Server (or Postgres if you need multiple servers and licensing costs become a factor). Other than that, just learn how to instrument your system so you can analyze it to find out where the bottlenecks are. Note that I've never actually done any of this, it's just what I've gleaned from some articles on the net. IMHO, YMMV, IANAL, etc... - The information contained in this message is confidential proprietary property of Nelnet, Inc. and its affiliated companies (Nelnet) and is intended for the recipient only. Any reproduction, forwarding, or copying without the express permission of Nelnet is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to this e-mail. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: web application - student need help
Hmmm, interesting, a lot of the articles I remember reading don't seem to be available anymore. Too bad, there were some good war stories. They've probably all been pulled and reworked into Learning Tree Building Scalable Web Architectures courses. Most of what I could find about new Web 2.0 sites seems to be all touchy-feely user experience-oriented stuff, no tech details on what it actually takes to generate a tag cloud or keep response time beneath the magic 3-second threshold. Here's some stuff I did manage to come up with: A description of Slashdot's current setup (actually a few years old): http://slashdot.org/faq/tech.shtml#te050 Here's a story on Slashdot asking basically the same question the original poster did: http://ask.slashdot.org/article.pl?sid=05/05/26/1433202 A description of the growing pains of Anandtech (another geek site): http://www.anandtech.com/printarticle.aspx?i=2136 A PDF showing the infrastructure of Flickr: http://www.niallkennedy.com/blog/uploads/flickr_php.pdf Probably the most relevant -- a post describing how one site survived a Slashdotting (with a 466MHz Celeron on a DSL line): http://devnulled.com/content/2005/07/surviving-a-slashdotting-with-a-celeron -466-my-slashdot-experience/ | -Original Message- | From: Ross, Scott [mailto:[EMAIL PROTECTED] | Sent: Monday, 08 January, 2007 10:24 | To: Tomcat Users List | Subject: RE: web application - student need help | | Tracy Nelson. | Out of curiosity, can you point to some articles relating to the growing | pains you mentioned regarding Slashdot, Granddaddy and MySpace? | | Thanks | Scott Ross | | -Original Message- | From: Nelson, Tracy M. [mailto:[EMAIL PROTECTED] | Sent: Monday, January 08, 2007 11:01 AM | To: Tomcat Users List | Subject: RE: web application - student need help | | | From: Michael Ni [mailto:[EMAIL PROTECTED] | | Sent: Friday, 05 January, 2007 16:38 | | | | even with connection pooling, how many connections are we looking at | here? | | if my project works as intended, im predicting from 30 to 1000 poeple | | simultaneously hitting tomcat and sql server. | | If you're just on a cable modem, I wouldn't worry about it. Your | network bandwidth will give our before your connection limit. | | | i remember when websites like friendster.com came out, it was really | slow. | | now it is much faster, do you guys know where does a student learn | | about how to handle high traffic web applications? is there any | | classes? | | Your best bet is to read up on other site that had growing pains | (MySpace, Flickr or the granddaddy, Slashdot) and find out what they | did. For the most part, you'll have to find a service provider that has | the pipes you need for a price you can afford. Then worry about | partitioning your set-up: | break it up into web servers, app servers (Tomcat), and database | servers. | Try to split your app into static and dynamic pieces, that'll | (theoretically) let you cache static content (icons, logos, boilerplate | text) on the web server, which will help your response time. If your | database needs are simple (90% reads, most reads from a single table) | consider going with MySQL. It's proven itself many times over in | high-traffic sites. If you have any kind of real database needs, | though (transactions, complex joins, multiple concurrent updates) you'd | be better off sticking with SQL Server (or Postgres if you need multiple | servers and licensing costs become a factor). Other than that, just | learn how to instrument your system so you can analyze it to find out | where the bottlenecks are. | | Note that I've never actually done any of this, it's just what I've | gleaned from some articles on the net. IMHO, YMMV, IANAL, etc... | | - | | The information contained in this message is confidential proprietary | property of Nelnet, Inc. and its affiliated companies (Nelnet) and is | intended for the recipient only. | Any reproduction, forwarding, or copying without the express permission | of Nelnet is strictly prohibited. If you have received this | communication in error, please notify us immediately by replying to this | e-mail. | | | | - | To start a new topic, e-mail: users@tomcat.apache.org | To unsubscribe, e-mail: [EMAIL PROTECTED] | For additional commands, e-mail: [EMAIL PROTECTED] | | | | - | To start a new topic, e-mail: users@tomcat.apache.org | To unsubscribe, e-mail: [EMAIL PROTECTED] | For additional commands, e-mail: [EMAIL PROTECTED] - The information contained in this message is confidential proprietary property of Nelnet, Inc
Re: web application - student need help
well tracy i have to dfind hw traffic should be control bt ya for database u have to use JDBC pool bean it ll make ur application much fast.. On 1/8/07, Nelson, Tracy M. [EMAIL PROTECTED] wrote: | From: Michael Ni [mailto:[EMAIL PROTECTED] | Sent: Friday, 05 January, 2007 16:38 | | even with connection pooling, how many connections are we looking at here? | if my project works as intended, im predicting from 30 to 1000 poeple | simultaneously hitting tomcat and sql server. If you're just on a cable modem, I wouldn't worry about it. Your network bandwidth will give our before your connection limit. | i remember when websites like friendster.com came out, it was really slow. | now it is much faster, do you guys know where does a student learn | about how to handle high traffic web applications? is there any | classes? Your best bet is to read up on other site that had growing pains (MySpace, Flickr or the granddaddy, Slashdot) and find out what they did. For the most part, you'll have to find a service provider that has the pipes you need for a price you can afford. Then worry about partitioning your set-up: break it up into web servers, app servers (Tomcat), and database servers. Try to split your app into static and dynamic pieces, that'll (theoretically) let you cache static content (icons, logos, boilerplate text) on the web server, which will help your response time. If your database needs are simple (90% reads, most reads from a single table) consider going with MySQL. It's proven itself many times over in high-traffic sites. If you have any kind of real database needs, though (transactions, complex joins, multiple concurrent updates) you'd be better off sticking with SQL Server (or Postgres if you need multiple servers and licensing costs become a factor). Other than that, just learn how to instrument your system so you can analyze it to find out where the bottlenecks are. Note that I've never actually done any of this, it's just what I've gleaned from some articles on the net. IMHO, YMMV, IANAL, etc... - The information contained in this message is confidential proprietary property of Nelnet, Inc. and its affiliated companies (Nelnet) and is intended for the recipient only. Any reproduction, forwarding, or copying without the express permission of Nelnet is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to this e-mail. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Chaitya Shah
Re: web application - student need help
| | i remember when websites like friendster.com came out, it was really | slow. | | now it is much faster, do you guys know where does a student learn | | about how to handle high traffic web applications? is there any | | classes? http://www.kegel.com/c10k.html is a good place to start Andrew - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: web application - student need help Thank You's
I just want to thank everyone who provided input to my question. I am going to try to set up the connection pool. By the way. I have another question about authentication to websites. For authentication, currently I bascially have a Person table, where one field is your permission. example table person username = bob, password = wawawawa permission level = admin So during login, after a person enters his username and password, it will check to see if the username exists in the person table. If it does exist, it will verify the password and return his permission. That permission is stored in the session, and each jsp page it will check to see if his permission is correct. If a person's permission is wrong, it will redirect you to another page. Although this method works, I dont know if it is very professional. Does anyone have any ideas how to set up a professional style authentication system? Something a business would use where exposing customer information is a liability. mike _ Communicate instantly! Use your Hotmail address to sign into Windows Live Messenger now. http://get.live.com/messenger/overview - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: web application - student need help Thank You's
Mike, Using rdbms table for authentication isn't bad, but make sure you store only the hashed password, So even DBA can't read them. When user enters the password again hash it and compare with the db hashed password. Make sure you enabled https, so that even network snuffers can't read them. In general, Organizations normally uses LDAP service to store password, so every application can be accessed using same user-id and password (Or using some sort of SSO application), If you need to know more about it, dig-out openldap. Storing roles (or permissions) in session is good, so it reduces the db operation. Hopefully you will also get more answers soon :). I am also curious to know more about it from others. Regards, Mohan -Original Message- From: Michael Ni [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 09, 2007 9:17 AM To: users@tomcat.apache.org Subject: RE: web application - student need help Thank You's I just want to thank everyone who provided input to my question. I am going to try to set up the connection pool. By the way. I have another question about authentication to websites. For authentication, currently I bascially have a Person table, where one field is your permission. example table person username = bob, password = wawawawa permission level = admin So during login, after a person enters his username and password, it will check to see if the username exists in the person table. If it does exist, it will verify the password and return his permission. That permission is stored in the session, and each jsp page it will check to see if his permission is correct. If a person's permission is wrong, it will redirect you to another page. Although this method works, I dont know if it is very professional. Does anyone have any ideas how to set up a professional style authentication system? Something a business would use where exposing customer information is a liability. mike _ Communicate instantly! Use your Hotmail address to sign into Windows Live Messenger now. http://get.live.com/messenger/overview - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This email is confidential. If you are not the addressee tell the sender immediately and destroy this email without using, sending or storing it. Emails are not secure and may suffer errors, viruses, delay, interception and amendment. Standard Chartered PLC and subsidiaries (SCGroup) do not accept liability for damage caused by this email and may monitor email traffic. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: web application - student need help
Hi Caroline, first i want to thank you for the time you spent to answer my reply. second, in your example, which imports are irrelavant to me? i'm assuming i dont need any of the artimus stuff, whatever that is. thanks mike ni From: Caroline Jen [EMAIL PROTECTED] Reply-To: Tomcat Users List users@tomcat.apache.org To: Tomcat Users List users@tomcat.apache.org Subject: Re: web application - student need help Date: Sun, 7 Jan 2007 15:59:16 -0800 (PST) For configuring a connection pool, follow this URL: http://jakarta.apache.org/commons/dbcp/configuration.html 1. The JDBC driver JAR must go in the common/lib directory (because for connection pooling it needs to be accessible to both Tomcat and the web app). 2. DBCP is built into Tomcat so you don't need to install a JAR for that. 3. Always close the connection when you're done with it. The configuration shown below is what in my Tomcat's server.xml file: DefaultContext Resource name=jdbc/MySQLDB auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/MySQLDB parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter parameter nameurl/name valuejdbc:mysql://localhost:3306/artimus?autoReconnect=true/value /parameter parameter nameusername/name valuejavauser/value /parameter parameter namepassword/name valuejavadude/value /parameter parameter namemaxActive/name value20/value /parameter parameter namemaxIdle/name value30/value /parameter parameter namemaxWait/name value1/value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value60/value /parameter parameter namelogAbandoned/name valuetrue/value /parameter /ResourceParams /DefaultContext /Host Then, the code to get a DB connection is: import java.sql.Connection; import java.sql.SQLException; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.sql.DataSource; public class DBConnection { public static Connection getDBConnection() throws SQLException { Connection conn = null; try { InitialContext ctx = new InitialContext(); DataSource ds = ( DataSource ) ctx.lookup( java:comp/env/jdbc/MySQLDB ); try { conn = ds.getConnection(); } catch( SQLException e ) { System.out.println( Open connection failure: + e.getMessage() ); } } catch( NamingException nEx ) { nEx.printStackTrace(); } return conn; } } Then, the code to use the DB connection: import java.io.IOException; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Collection; import org.apache.artimus.message.ThreadBean; import org.apache.artimus.message.PostBean; import org.apache.artimus.message.AttachmentBean; import org.apache.artimus.message.exceptions.MessageDAOSysException; import org.apache.artimus.message.exceptions.ObjectNotFoundException; import org.apache.artimus.message.exceptions.AssertionException; import org.apache.artimus.message.exceptions.DatabaseException; import org.apache.artimus.message.exceptions.BadInputException; import org.apache.artimus.ConnectionPool.DBConnection; public class MySQLMessageDAO implements MessageDAO { public void createThread( String receiver, String sender, String title, String lastPostMemberName, String threadTopic, String threadBody, Timestamp threadCreationDate, Timestamp threadLastPostDate, int threadType, int threadOption, int threadStatus, int threadViewCount, int threadReplyCount, int threadDuration ) throws MessageDAOSysException
Re: web application - student need help
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); try { conn = DBConnection.getDBConnection(); stmt = conn.prepareStatement( insertSQL ); stmt.setString( 1, receiver ); stmt.setString( 2, sender ); stmt.setString( 3, title ); stmt.setString( 4, lastPostMemberName ); stmt.setString( 5, threadTopic ); stmt.setString( 6, threadBody ); stmt.setTimestamp( 7, threadCreationDate ); stmt.setTimestamp( 8, threadLastPostDate ); stmt.setInt( 9, threadType ); stmt.setInt( 10, threadOption ); stmt.setInt( 11, threadStatus ); stmt.setInt( 12, threadViewCount ); stmt.setInt( 13, threadReplyCount ); stmt.setInt( 14, threadDuration ); stmt.executeUpdate(); // m_dirty = true; } catch( SQLException se ) { System.out.println( se.getMessage() ); se.printStackTrace(); throw new MessageDAOSysException( Error executing SQL in ThreadHandler.createThread. ); } finally { if ( conn != null ) { try { stmt.close(); stmt = null; conn.close(); } catch( SQLException sqlEx ) { System.out.println( Problem occurs while closing + sqlEx ); } conn = null; } } } } -Caroline --- Michael Ni [EMAIL PROTECTED] wrote: thx caroline From: Caroline Jen [EMAIL PROTECTED] Reply-To: Tomcat Users List users@tomcat.apache.org To: Tomcat Users List users@tomcat.apache.org Subject: Re: web application - student need help Date: Fri, 5 Jan 2007 13:42:18 -0800 (PST) Did you configure a connection pool in Tomcat? Then, get a connection object from the pool for each data search method invocation. I am at work now. I do not have the configuration with me. I can post the configuration and the database access code when I get home. Meanwhile, do a search on the internet. --- Michael Ni [EMAIL PROTECTED] wrote: i don't get any error when there isn't that much traffic but i dont close my jdbc connections, could that be a problem? this is the function i use to query public ResultSet getData(String queryStr) throws Exception { try { DBConstants db = new DBConstants(); Class.forName(db.getDrivername()); Connection conn; conn = DriverManager.getConnection(jdbc:microsoft:sqlserver:// + db.getHostname() + , + db.getUsername() + , + db.getPassword() + ); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(queryStr); return rs; } catch(Exception e) { e.printStackTrace(); System.out.println(getData error); throw new Exception(); } } -- then if i want to use it in a jsp page i will do something like this % DBPoolBean dbpb = new DBPoolBean(); ResultSet rs = dbpb.getData(SELECT * FROM drops order by hnm, itemname_en); while ( rs.next() ) { out.println(trtd width=\50\ + rs.getString(hnm) + /td); out.println(td width=\50\ + rs.getString(itemname_en) + /td/tr); } % From: Darek Czarkowski [EMAIL PROTECTED] Reply-To: Tomcat Users List users@tomcat.apache.org To: Tomcat Users List users@tomcat.apache.org Subject: Re: web application - student need help Date: Fri, 05 Jan 2007 12:52:19 -0800 Michael Ni wrote: the web application uses simple queries, like search a table for a certain condition. i realize when multiple people access the database it hangs, and causes the jsp pages to error. Just a guess, your connection to the database is a problem, perhaps errors in queries, not closed connections. What are the error messages? (page/log) -- Darek Czarkowski Ph: 604 294 6557 (Ext. 113) Fx: 604 294 6507 www.infinitesource.ca darekc at infinitesource dot ca - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Type your favorite song. Get a customized station. Try MSN Radio powered by Pandora. http://radio.msn.com/?icid
Re: web application - student need help
When the jsp shows error, its about exception right ? what is the exception and what does it says ? On 1/6/07, Michael Ni [EMAIL PROTECTED] wrote: Hi i'm doing a web application to help manage players for the online game Final Fantasy XI. Im using tomcat, sqlserver2000, and jsp. both sqlserver and tomcat are set up on the same computer. computer is pentium 2.8 GHZ with 512 RAM. im on cable internet the web application uses simple queries, like search a table for a certain condition. i realize when multiple people access the database it hangs, and causes the jsp pages to error. Is it mainly tomcat, or sql server? anyone have any experience on setting up websites to handle a lot of traffic? here is my site project http://66.215.70.71/ thx mike _ Get FREE Web site and company branded e-mail from Microsoft Office Live http://clk.atdmt.com/MRT/go/mcrssaub0050001411mrt/direct/01/ - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- -Andre- People see things the way they are and say why ? I see things that never were and say Why not ?
Re: web application - student need help
I think u should use JDBC POOL BEAN concept upto my knowledge after using this concept it will not hang ur jsp page n by d way wht error it throw?? On 1/8/07, Andre Prasetya [EMAIL PROTECTED] wrote: When the jsp shows error, its about exception right ? what is the exception and what does it says ? On 1/6/07, Michael Ni [EMAIL PROTECTED] wrote: Hi i'm doing a web application to help manage players for the online game Final Fantasy XI. Im using tomcat, sqlserver2000, and jsp. both sqlserver and tomcat are set up on the same computer. computer is pentium 2.8 GHZ with 512 RAM. im on cable internet the web application uses simple queries, like search a table for a certain condition. i realize when multiple people access the database it hangs, and causes the jsp pages to error. Is it mainly tomcat, or sql server? anyone have any experience on setting up websites to handle a lot of traffic? here is my site project http://66.215.70.71/ thx mike _ Get FREE Web site and company branded e-mail from Microsoft Office Live http://clk.atdmt.com/MRT/go/mcrssaub0050001411mrt/direct/01/ - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- -Andre- People see things the way they are and say why ? I see things that never were and say Why not ? -- Chaitya Shah
Re: web application - student need help
When the jsp shows error, its about exception right ? what is the exception and what does it says ? On 1/6/07, Michael Ni [EMAIL PROTECTED] wrote: Hi i'm doing a web application to help manage players for the online game Final Fantasy XI. Im using tomcat, sqlserver2000, and jsp. both sqlserver and tomcat are set up on the same computer. computer is pentium 2.8 GHZ with 512 RAM. im on cable internet the web application uses simple queries, like search a table for a certain condition. i realize when multiple people access the database it hangs, and causes the jsp pages to error. Is it mainly tomcat, or sql server? anyone have any experience on setting up websites to handle a lot of traffic? here is my site project http://66.215.70.71/ thx mike _ Get FREE Web site and company branded e-mail from Microsoft Office Live http://clk.atdmt.com/MRT/go/mcrssaub0050001411mrt/direct/01/ - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- -Andre- People see things the way they are and say why ? I see things that never were and say Why not ?
Re: web application - student need help
Michael Ni wrote: the web application uses simple queries, like search a table for a certain condition. i realize when multiple people access the database it hangs, and causes the jsp pages to error. Just a guess, your connection to the database is a problem, perhaps errors in queries, not closed connections. What are the error messages? (page/log) -- Darek Czarkowski Ph: 604 294 6557 (Ext. 113) Fx: 604 294 6507 www.infinitesource.ca darekc at infinitesource dot ca - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: web application - student need help
i don't get any error when there isn't that much traffic but i dont close my jdbc connections, could that be a problem? this is the function i use to query public ResultSet getData(String queryStr) throws Exception { try { DBConstants db = new DBConstants(); Class.forName(db.getDrivername()); Connection conn; conn = DriverManager.getConnection(jdbc:microsoft:sqlserver:// + db.getHostname() + , + db.getUsername() + , + db.getPassword() + ); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(queryStr); return rs; } catch(Exception e) { e.printStackTrace(); System.out.println(getData error); throw new Exception(); } } -- then if i want to use it in a jsp page i will do something like this % DBPoolBean dbpb = new DBPoolBean(); ResultSet rs = dbpb.getData(SELECT * FROM drops order by hnm, itemname_en); while ( rs.next() ) { out.println(trtd width=\50\ + rs.getString(hnm) + /td); out.println(td width=\50\ + rs.getString(itemname_en) + /td/tr); } % From: Darek Czarkowski [EMAIL PROTECTED] Reply-To: Tomcat Users List users@tomcat.apache.org To: Tomcat Users List users@tomcat.apache.org Subject: Re: web application - student need help Date: Fri, 05 Jan 2007 12:52:19 -0800 Michael Ni wrote: the web application uses simple queries, like search a table for a certain condition. i realize when multiple people access the database it hangs, and causes the jsp pages to error. Just a guess, your connection to the database is a problem, perhaps errors in queries, not closed connections. What are the error messages? (page/log) -- Darek Czarkowski Ph: 604 294 6557 (Ext. 113) Fx: 604 294 6507 www.infinitesource.ca darekc at infinitesource dot ca - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Type your favorite song. Get a customized station. Try MSN Radio powered by Pandora. http://radio.msn.com/?icid=T002MSN03A07001 - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: web application - student need help
Did you configure a connection pool in Tomcat? Then, get a connection object from the pool for each data search method invocation. I am at work now. I do not have the configuration with me. I can post the configuration and the database access code when I get home. Meanwhile, do a search on the internet. --- Michael Ni [EMAIL PROTECTED] wrote: i don't get any error when there isn't that much traffic but i dont close my jdbc connections, could that be a problem? this is the function i use to query public ResultSet getData(String queryStr) throws Exception { try { DBConstants db = new DBConstants(); Class.forName(db.getDrivername()); Connection conn; conn = DriverManager.getConnection(jdbc:microsoft:sqlserver:// + db.getHostname() + , + db.getUsername() + , + db.getPassword() + ); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(queryStr); return rs; } catch(Exception e) { e.printStackTrace(); System.out.println(getData error); throw new Exception(); } } -- then if i want to use it in a jsp page i will do something like this % DBPoolBean dbpb = new DBPoolBean(); ResultSet rs = dbpb.getData(SELECT * FROM drops order by hnm, itemname_en); while ( rs.next() ) { out.println(trtd width=\50\ + rs.getString(hnm) + /td); out.println(td width=\50\ + rs.getString(itemname_en) + /td/tr); } % From: Darek Czarkowski [EMAIL PROTECTED] Reply-To: Tomcat Users List users@tomcat.apache.org To: Tomcat Users List users@tomcat.apache.org Subject: Re: web application - student need help Date: Fri, 05 Jan 2007 12:52:19 -0800 Michael Ni wrote: the web application uses simple queries, like search a table for a certain condition. i realize when multiple people access the database it hangs, and causes the jsp pages to error. Just a guess, your connection to the database is a problem, perhaps errors in queries, not closed connections. What are the error messages? (page/log) -- Darek Czarkowski Ph: 604 294 6557 (Ext. 113) Fx: 604 294 6507 www.infinitesource.ca darekc at infinitesource dot ca - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Type your favorite song. Get a customized station. Try MSN Radio powered by Pandora. http://radio.msn.com/?icid=T002MSN03A07001 - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: web application - student need help
Michael Ni wrote: public ResultSet getData(String queryStr) throws Exception { try { DBConstants db = new DBConstants(); Class.forName(db.getDrivername()); Connection conn; conn = DriverManager.getConnection(jdbc:microsoft:sqlserver:// + db.getHostname() + , + db.getUsername() + , + db.getPassword() + ); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(queryStr); return rs; } catch(Exception e) { e.printStackTrace(); System.out.println(getData error); throw new Exception(); } } Add |finally { try {if (rs != null) rs.close();} catch (SQLException e) {} try {if (stmt != null) stmt.close();} catch (SQLException e) {} try {if (conn != null) conn.close();} catch (SQLException e) {} }| And return an object rather than ResultSet. Read about connection pooling, here is an example: http://www.onjava.com/pub/a/onjava/2006/04/19/database-connection-pooling-with-tomcat.html?page=1 -- Darek Czarkowski www.infinitesource.ca darekc at infinitesource dot ca - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: web application - student need help
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael, Michael Ni wrote: i don't get any error when there isn't that much traffic but i dont close my jdbc connections, could that be a problem? Oh, yeah. Failing to close connections is very likely to give you errors, as you will end up running out of memory, or the database server will cut you off when you reach the maximum number of connections. Someone else mentioned the use of a connection pool, which I highly recommend. You can use Tomcat to configure a connection pool and then obtain a JDBC DataSource through JNDI. Then, you can get a connection from that for use. It's not really as complicated as it sounds ;) try { DBConstants db = new DBConstants(); Class.forName(db.getDrivername()); Connection conn; conn = DriverManager.getConnection(jdbc:microsoft:sqlserver:// + db.getHostname() + , + db.getUsername() + , + db.getPassword() + ); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(queryStr); return rs; } catch(Exception e) { e.printStackTrace(); System.out.println(getData error); throw new Exception(); } } Let me suggest some changes to your code: Connection conn = null; Statement stmt = null; ResultSet rs = null; try { conn = (get connection from jndi datasource) stmt = conn.createStatement(); rs = stmt.executeQuery(queryStr); // Package the results into Java objects // instead of using the ResultSet directly return ??; } catch (SQLException sqle) // Don't catch Exception unless you have to { sqle.printStackTrace(); System.err.println(getData error); // System.err is better throw sqle; // No need for a new exception; use existing one } finally { if(null != rs) try { rs.close(); } catch (SQLException sqle) { System.err.println(Could not close ResultSet); } if(null != stmt) try { stmt.close(); } catch (SQLException sqle) { System.err.println(Could not close Statement); } if(null != conn) try { conn.close(); } catch (SQLException sqle) { System.err.println(Could not close Connection); } } This is about as clean as you can get. If you must return the ResultSet to to the calling method, then you will have to do something different. I recommend you copy from the ResultSet into something like an ArraryList of objects specific for your needs. One last thing: when possible, use PreparedStatement instead of Statement for your queries. The use of this class goes a long way towards protecting you against SQL injection attacks (where people can do nasty things like drop tables and stuff). It requires a bit more setup (especially if you are trying to write a reusable method to execute all your queries) but I think it's worth it. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFnszE9CaO5/Lv0PARAjlpAJ9yhTlVRo5InvBnHsTIlTpIHJ5/+wCgtZMx SoN9PKZ3jxEx4YflzuLg97o= =3nJD -END PGP SIGNATURE- - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: web application - student need help
You need to configure your database connection pool so that it accepts unlimited users or the certain limit that you require. Check the tomcat website for the syntax.
Re: web application - student need help
start with DriverManagerConnectionFactory http://svn.apache.org/viewvc/jakarta/commons/proper/dbcp/trunk/doc/ManualPoolingDriverExample.java?view=log Then use a connection from the DriverManagerConnectionFactory to populate a Datasource http://svn.apache.org/viewvc/jakarta/commons/proper/dbcp/trunk/doc/ManualPoolingDataSourceExample.java?view=log jsp Example using PoolableConnectionFactory http://svn.apache.org/viewvc/jakarta/commons/proper/dbcp/trunk/doc/poolingDriverExample.jocl.sample?view=log I am not familiar with DBPoolBean (can you illustrate the location of the jars and working sample code..?) I found this taglib code which build an options list (from a connection obtained from a ConnectionPool) http://archives.java.sun.com/cgi-bin/wa?A2=ind0009L=jsp-interestP=57293 HTH, M- --- This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. --- Le présent message électronique (y compris les pièces qui y sont annexées, le cas échéant) s'adresse au destinataire indiqué et peut contenir des renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le destinataire de ce document, nous vous signalons qu'il est strictement interdit de le diffuser, de le distribuer ou de le reproduire. - Original Message - From: Caroline Jen [EMAIL PROTECTED] To: Tomcat Users List users@tomcat.apache.org Sent: Friday, January 05, 2007 4:42 PM Subject: Re: web application - student need help Did you configure a connection pool in Tomcat? Then, get a connection object from the pool for each data search method invocation. I am at work now. I do not have the configuration with me. I can post the configuration and the database access code when I get home. Meanwhile, do a search on the internet. --- Michael Ni [EMAIL PROTECTED] wrote: i don't get any error when there isn't that much traffic but i dont close my jdbc connections, could that be a problem? this is the function i use to query public ResultSet getData(String queryStr) throws Exception { try { DBConstants db = new DBConstants(); Class.forName(db.getDrivername()); Connection conn; conn = DriverManager.getConnection(jdbc:microsoft:sqlserver:// + db.getHostname() + , + db.getUsername() + , + db.getPassword() + ); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(queryStr); return rs; } catch(Exception e) { e.printStackTrace(); System.out.println(getData error); throw new Exception(); } } -- then if i want to use it in a jsp page i will do something like this % DBPoolBean dbpb = new DBPoolBean(); ResultSet rs = dbpb.getData(SELECT * FROM drops order by hnm, itemname_en); while ( rs.next() ) { out.println(trtd width=\50\ + rs.getString(hnm) + /td); out.println(td width=\50\ + rs.getString(itemname_en) + /td/tr); } % From: Darek Czarkowski [EMAIL PROTECTED] Reply-To: Tomcat Users List users@tomcat.apache.org To: Tomcat Users List users@tomcat.apache.org Subject: Re: web application - student need help Date: Fri, 05 Jan 2007 12:52:19 -0800 Michael Ni wrote: the web application uses simple queries, like search a table for a certain condition. i realize when multiple people access the database it hangs, and causes the jsp pages to error. Just a guess, your connection to the database is a problem, perhaps errors in queries, not closed connections. What are the error messages? (page/log) -- Darek Czarkowski Ph: 604 294 6557 (Ext. 113) Fx: 604 294 6507 www.infinitesource.ca darekc at infinitesource dot ca - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Type your favorite song. Get a customized station. Try MSN Radio powered by Pandora. http://radio.msn.com/?icid=T002MSN03A07001 - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED
Re: web application - student need help
thx caroline From: Caroline Jen [EMAIL PROTECTED] Reply-To: Tomcat Users List users@tomcat.apache.org To: Tomcat Users List users@tomcat.apache.org Subject: Re: web application - student need help Date: Fri, 5 Jan 2007 13:42:18 -0800 (PST) Did you configure a connection pool in Tomcat? Then, get a connection object from the pool for each data search method invocation. I am at work now. I do not have the configuration with me. I can post the configuration and the database access code when I get home. Meanwhile, do a search on the internet. --- Michael Ni [EMAIL PROTECTED] wrote: i don't get any error when there isn't that much traffic but i dont close my jdbc connections, could that be a problem? this is the function i use to query public ResultSet getData(String queryStr) throws Exception { try { DBConstants db = new DBConstants(); Class.forName(db.getDrivername()); Connection conn; conn = DriverManager.getConnection(jdbc:microsoft:sqlserver:// + db.getHostname() + , + db.getUsername() + , + db.getPassword() + ); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(queryStr); return rs; } catch(Exception e) { e.printStackTrace(); System.out.println(getData error); throw new Exception(); } } -- then if i want to use it in a jsp page i will do something like this % DBPoolBean dbpb = new DBPoolBean(); ResultSet rs = dbpb.getData(SELECT * FROM drops order by hnm, itemname_en); while ( rs.next() ) { out.println(trtd width=\50\ + rs.getString(hnm) + /td); out.println(td width=\50\ + rs.getString(itemname_en) + /td/tr); } % From: Darek Czarkowski [EMAIL PROTECTED] Reply-To: Tomcat Users List users@tomcat.apache.org To: Tomcat Users List users@tomcat.apache.org Subject: Re: web application - student need help Date: Fri, 05 Jan 2007 12:52:19 -0800 Michael Ni wrote: the web application uses simple queries, like search a table for a certain condition. i realize when multiple people access the database it hangs, and causes the jsp pages to error. Just a guess, your connection to the database is a problem, perhaps errors in queries, not closed connections. What are the error messages? (page/log) -- Darek Czarkowski Ph: 604 294 6557 (Ext. 113) Fx: 604 294 6507 www.infinitesource.ca darekc at infinitesource dot ca - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Type your favorite song. Get a customized station. Try MSN Radio powered by Pandora. http://radio.msn.com/?icid=T002MSN03A07001 - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ From photos to predictions, The MSN Entertainment Guide to Golden Globes has it all. http://tv.msn.com/tv/globes2007/?icid=nctagline1 - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: web application - student need help
great replies from everyone. even with connection pooling, how many connections are we looking at here? if my project works as intended, im predicting from 30 to 1000 poeple simultaneously hitting tomcat and sql server. i remember when websites like friendster.com came out, it was really slow. now it is much faster, do you guys know where does a student learn about how to handle high traffic web applications? is there any classes? From: Christopher Schultz [EMAIL PROTECTED] Reply-To: Tomcat Users List users@tomcat.apache.org To: Tomcat Users List users@tomcat.apache.org Subject: Re: web application - student need help Date: Fri, 05 Jan 2007 17:10:13 -0500 -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael, Michael Ni wrote: i don't get any error when there isn't that much traffic but i dont close my jdbc connections, could that be a problem? Oh, yeah. Failing to close connections is very likely to give you errors, as you will end up running out of memory, or the database server will cut you off when you reach the maximum number of connections. Someone else mentioned the use of a connection pool, which I highly recommend. You can use Tomcat to configure a connection pool and then obtain a JDBC DataSource through JNDI. Then, you can get a connection from that for use. It's not really as complicated as it sounds ;) try { DBConstants db = new DBConstants(); Class.forName(db.getDrivername()); Connection conn; conn = DriverManager.getConnection(jdbc:microsoft:sqlserver:// + db.getHostname() + , + db.getUsername() + , + db.getPassword() + ); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(queryStr); return rs; } catch(Exception e) { e.printStackTrace(); System.out.println(getData error); throw new Exception(); } } Let me suggest some changes to your code: Connection conn = null; Statement stmt = null; ResultSet rs = null; try { conn = (get connection from jndi datasource) stmt = conn.createStatement(); rs = stmt.executeQuery(queryStr); // Package the results into Java objects // instead of using the ResultSet directly return ??; } catch (SQLException sqle) // Don't catch Exception unless you have to { sqle.printStackTrace(); System.err.println(getData error); // System.err is better throw sqle; // No need for a new exception; use existing one } finally { if(null != rs) try { rs.close(); } catch (SQLException sqle) { System.err.println(Could not close ResultSet); } if(null != stmt) try { stmt.close(); } catch (SQLException sqle) { System.err.println(Could not close Statement); } if(null != conn) try { conn.close(); } catch (SQLException sqle) { System.err.println(Could not close Connection); } } This is about as clean as you can get. If you must return the ResultSet to to the calling method, then you will have to do something different. I recommend you copy from the ResultSet into something like an ArraryList of objects specific for your needs. One last thing: when possible, use PreparedStatement instead of Statement for your queries. The use of this class goes a long way towards protecting you against SQL injection attacks (where people can do nasty things like drop tables and stuff). It requires a bit more setup (especially if you are trying to write a reusable method to execute all your queries) but I think it's worth it. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFnszE9CaO5/Lv0PARAjlpAJ9yhTlVRo5InvBnHsTIlTpIHJ5/+wCgtZMx SoN9PKZ3jxEx4YflzuLg97o= =3nJD -END PGP SIGNATURE- - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Get live scores and news about your team: Add the Live.com Football Page www.live.com/?addtemplate=footballicid=T001MSN30A0701 - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: web application - student need help
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael, Michael Ni wrote: even with connection pooling, how many connections are we looking at here? if my project works as intended, im predicting from 30 to 1000 poeple simultaneously hitting tomcat and sql server. What you really need to know is how many database queries will will need to support. Just because 1000 people may be logged-in at the same time doesn't mean that you have to handle 1000 simultaneous requests. You might be able to get away with as few as 50 connections in your pool to start out with. You are likely to experience slow growth at the beginning, so just do your own wall-clock testing on the live site occasionally to determine if it's fast enough. i remember when websites like friendster.com came out, it was really slow. now it is much faster, do you guys know where does a student learn about how to handle high traffic web applications? is there any classes? Tuning like this is a black art. You really need to either get someone who knows what they are doing, or stumble through it yourself. Want my advice? Put it out there and see how it performs. If it sucks, make improvements. Make sure you have your database well-optimized. Most database rely not only on indexes (which are so important I cannot stress that enough) but also on their own black magic that analyzes the actual content of the tables for optimization. Often, you can simply issue an OPTIMIZE TABLE query on the table and make it perform better. Some database perform better than others. For instance, I think that MySQL cannot be beat when it comes to read-only queries. They also have a handful of different table types that makes it easy to optimize for your expected usage (for instance, if you don't need transactions, you can use a /much/ faster table implementation and get better performance). Good luck! - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFntWX9CaO5/Lv0PARAndeAJ9m3BTh5VC2EyXEVjkU8JXp4KcLHACdH59l m64lXBbWkKaosUzw0Z+5q6M= =Gayw -END PGP SIGNATURE- - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: web application - student need help
Hi, Following is configuration for Tomcat Connection pool which you have to write in your context.xml. If you are using Tomcat Admin, you specify parameters in web GUI. Resource name=jdbc/mydbconn type=javax.sql.DataSource / ResourceParams name=jdbc/mydbconn parameter namemaxWait/name value5000/value /parameter parameter namemaxActive/name value10/value /parameter parameter nameurl/name value*JDBC URL*/value /parameter parameter namedriverClassName/name value*DRIVER CLASS*/value /parameter parameter namemaxIdle/name value2/value /parameter parameter nameusername/name value*DB USERNAME*/value /parameter parameter namepassword/name value*DB PASSWORD*/value /parameter /ResourceParams Please refer to documentation (http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html) if you want fine tune parameters like maxWait, maxActive, maxIdle, etc. and believe me you will find it very useful. Now how to use that connection in your application pages. Following is the code snippet that you can use it. Context init = new InitialContext(); Context ctx = (Context) init.lookup(java:comp/env); DataSource ds = (DataSource) ctx.lookup(jdbc/mydbconn); //BE CAREFUL ABOUT NAME - jdbc/mydbconn. public ... getData(...) { Connection conn = null; Statement stmt = null; ResultSet rs = null; try { conn = ds.getConnection(); stmt = conn.createStatement(); ... ... ... rs.close(); rs = null; stmt.close(); stmt = null; conn.close(); // Return to connection pool conn = null; } catch(SQLException e) { e.printStackTrace(); } finally { // Always make sure result sets and statements are closed, // and the connection is returned to the pool if (rs != null) { try { rs.close(); } catch (SQLException e) { ; } rs = null; } if (stmt != null) { try { stmt.close(); } catch (SQLException e) { ; } stmt = null; } if (conn != null) { try { conn.close(); } catch (SQLException e) { ; } conn = null; } } ... } Also you can write generic bean and use it in your JSP pages. This way it will ease your work. About making website faster, there are many parameters involved. Above thing will definitely gain speed if you fine tune it based upon your application and hardware. Now if you want more speed, you can go with better hardware or provide more memory to tomcat. But first try above snippet. I am sure you won't need another machine. Regards, D --- Michael Ni [EMAIL PROTECTED] wrote: great replies from everyone. even with connection pooling, how many connections are we looking at here? if my project works as intended, im predicting from 30 to 1000 poeple simultaneously hitting tomcat and sql server. i remember when websites like friendster.com came out, it was really slow. now it is much faster, do you guys know where does a student learn about how to handle high traffic web applications? is there any classes? From: Christopher Schultz [EMAIL PROTECTED] Reply-To: Tomcat Users List users@tomcat.apache.org To: Tomcat Users List users@tomcat.apache.org Subject: Re: web application - student need help Date: Fri, 05 Jan 2007 17:10:13 -0500 -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael, Michael Ni wrote: i don't get any error when there isn't that much traffic but i dont close my jdbc connections, could that be a problem? Oh, yeah. Failing to close connections is very likely to give you errors, as you will end up running out of memory, or the database server will cut you off when you reach the maximum number of connections. Someone else mentioned the use of a connection pool, which I highly recommend. You can use Tomcat to configure a connection pool and then obtain a JDBC DataSource through JNDI. Then, you can get a connection from that for use. It's not really as complicated as it sounds ;) try { DBConstants db = new DBConstants(); Class.forName(db.getDrivername()); Connection conn; conn = DriverManager.getConnection(jdbc:microsoft:sqlserver:// + db.getHostname() + , + db.getUsername() + , + db.getPassword() + ); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(queryStr