mysql+jsp

Reply

Join Date: Mar 2008
Posts: 9
Reputation: nireekshan is an unknown quantity at this point 
Solved Threads: 0
nireekshan nireekshan is offline Offline
Newbie Poster

mysql+jsp

 
0
  #1
Apr 4th, 2008
hai
i am nireekshan
i am using mySql database in this i am create employe table
Now i am davalep One .HTML Page in this i am write the employe table fieldes-----------And write Jsp page inThis i write MYSQL CONNection code And Insert Prapared Staments
Now i am run TOMCat 5.0 Server,open .HTML page INSERT EMploye Fied Values Submet ok
next Work is Down NOT store data in database
plse see my program tell me any ERROR plse ...............
HTML..............>jsp.................;

  1. <%@ page import="javax.servlet.*" %>
  2. <%@ page import="javax.servlet.http.*" %>
  3. <%@ page import="java.io.*" %>
  4.  
  5. <%@ page import="java.sql.*" %>
  6. <%
  7.  
  8. String vemp_code=request.getParameter("emp_code");
  9. String vemp_name=request.getParameter("emp_name");
  10.  
  11. Connection conn = null;
  12. ResultSet rs=null;
  13. String url = "jdbc:mysql://localhost:3306/";
  14. String driverName = "com.mysql.jdbc.Driver";
  15. String userName = "roor";
  16. String password = "root";
  17. try{
  18. Class.forName(driverName).newInstance();
  19. conn = DriverManager.getConnection("jdbc:mysql://localhost/niree",userName,password);
  20. Statement stmt = conn.createStatement();
  21. stmt.executeUpdate("use newuser;");
  22. out.println(" connection is established");
  23.  
  24. //Statement stmt = conn.createStatement();
  25. //int val = //stmt.executeUpdate("INSERT employe VALUES(?,?)");
  26. PreparedStatement pst;
  27. pst=conn.prepareStatement(" insert into employe values(?,?)");
  28. pst.setString(1,vemp_code);
  29. pst.setString(2,vemp_name);
  30. }
  31. catch(Exception e){
  32. System.out.println("error occured");
  33. e.printStackTrace();
  34. }
  35.  
  36.  
  37.  
  38. %>
Last edited by peter_budo; Apr 4th, 2008 at 3:12 pm. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,600
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 462
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: mysql+jsp

 
0
  #2
Apr 7th, 2008
Don't write database connectivity code in a JSP; that's not what JSP's were meant for. Push all that database logic inside a servlet. Use JSP only as a presentation technology.

And BTW, have you hosted your files on the Tomcat server? What is the URL you are using to access your HTML? What kind of error do you get? Aren't the error logs useful?
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 440
Reputation: Sulley's Boo will become famous soon enough Sulley's Boo will become famous soon enough 
Solved Threads: 10
Sulley's Boo's Avatar
Sulley's Boo Sulley's Boo is offline Offline
Posting Pro in Training

Re: mysql+jsp

 
0
  #3
Apr 8th, 2008
and, this line is missing
  1. pst.executeUpdate();
right ppl?

*hides*
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: mysql+jsp

 
0
  #4
Apr 8th, 2008
I wouldn't know. As soon as I see a tag starting a scriptlet I quit reading and give the canned answer to not use Java code in JSP.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 17
Reputation: mr4top is an unknown quantity at this point 
Solved Threads: 0
mr4top's Avatar
mr4top mr4top is offline Offline
Newbie Poster

Re: mysql+jsp

 
0
  #5
Apr 8th, 2008
#
String userName = "roor";
#
String password = "root";

i think you should take care of Name
check it plase it should be ROOT not ROOR
Mahmoud Rizk
002-010 4411 540
Admin@ErpEgypt.com
Internet Marketing Consultant - Sales and Marketing Certified.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC