| | |
jsp with mysql connection
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2007
Posts: 15
Reputation:
Solved Threads: 0
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
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
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)
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)
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
----------------------------------------------
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
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.
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.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
![]() |
Similar Threads
- C++ and MySQL connection (C++)
- How to Connect MySQL from JSP Page (JSP)
- Problem adding registration data to mysql database (JSP)
- MySql connection question. (Java)
- connecting jsp with mysql database (JSP)
- remote mysql connection (MySQL)
- Cant get a free web host for JSP & MYSQL (JSP)
Other Threads in the JSP Forum
- Previous Thread: email sending from a jsp page after submit button
- Next Thread: How Get Date of "First Day of Current Week" in JSP
| Thread Tools | Search this Thread |
apache backbutton combobox connection database development directorystructure dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 network parameters passing ping printinserverinsteadofclient redirect request.getparameter response servlet servletdopost()readxml sessions software ssl state_saving_method stocks sun tomcat tutorial update video web






