RSS Forums RSS
Please support our JSP advertiser: Lunarpages JSP Web Hosting

Whats Wrongin folloowind code for connecting with mysql

Join Date: Feb 2006
Posts: 1,556
Reputation: masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light 
Rep Power: 11
Solved Threads: 144
masijade's Avatar
masijade masijade is online now Online
Posting Virtuoso

Re: Whats Wrongin folloowind code for connecting with mysql

  #2  
Oct 15th, 2007
1) This code should not be in a scriptlet. Move the query part out to a bean.

2) Use a connection pool, or open the connection in a session object (although this type of persistence is frowned upon) because opening a connection for every page load is extremely inefficient.

3) if you absolutely must use scriptlets (which you don't, but you may insist on it) then at least don't mix "html tag" strings into the middle of the scriptlet, that is just blurring the separation (and increasing the maintenance load) all that much more.

4) The user would generally be simply "root", as opposed to "root@localhost". The MySQL server will resolve the "@whatever" part itself, depending on where you connect from. Make sure you have the user@whatever login allowed over TCP in your MySQL configuration.

I think those are enough problems for now.
Last edited by masijade : Oct 15th, 2007 at 9:59 am. Reason: typo
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 6:20 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC