944,084 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Unsolved
  • Views: 7194
  • JSP RSS
Feb 8th, 2007
0

jsp with mysql connection

Expand Post »
in my each jsp page i have to write this code to connect with Mysql database

Class.forName("com.mysql.jdbc.Driver").newInstance();
String url ="jdbc:mysql://35.212.176.25/tri";
Connection con = DriverManager.getConnection(url,"root", "");

now i want to make this code in a separate jsp page and then only include this page in my current jsp page where ever necessary to connect with my Database like in PHP. Is it possible in Jsp . If yes pls tell me
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jeet_portal is offline Offline
18 posts
since Jan 2007
Feb 8th, 2007
0

Re: jsp with mysql connection

You should move it out to a Servlet, bean, custom JSTL tag, or other application context item. This type of code should never be found in a JSP.

Other than that, yes it is possible.

Try going through the following:
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/
(although it is one version outdated now)
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Feb 8th, 2007
0

Re: jsp with mysql connection

yes it's possible and no we're not going to tell you how to do it as it is (as you've already been told) extremely bad to do so.

It is in fact one of the reasons PHP is frowned upon by people who are serious about writing software rather than quickly hacking something together in the hope noone will ever have to change it.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: email sending from a jsp page after submit button
Next Thread in JSP Forum Timeline: How Get Date of "First Day of Current Week" in JSP





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC