User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 428,067 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,449 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 457 | Replies: 1
Reply
Join Date: May 2008
Posts: 1
Reputation: Rahul17 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Rahul17 Rahul17 is offline Offline
Newbie Poster

problem with connecting jsp page with mysql

  #1  
May 16th, 2008
I have written this code in Jsp file .
  1. <%
  2. Connection con=null;
  3. Statement st=null;
  4. PreparedStatement ps;
  5.  
  6. String nm=request.getParameter("tnm");
  7. String loc=request.getParameter("tlc");
  8.  
  9. try
  10. {
  11. Class.forName("com.mysql.jdbc.Driver");
  12. con=DriverManager.getConnection("jdbc:mysql://localhost:3306/rahul","root","root");
  13. st=con.createStatement();
  14. try
  15. {
  16. ps=con.prepareStatement("insert into dept(deptname,location) values(?,?)");
  17.  
  18. ps.setString(1,nm);
  19. ps.setString(2,loc);
  20.  
  21. ps.executeUpdate();
  22. out.println("Value inserted ");
  23. }
  24. catch(SQLException e)
  25. {
  26. out.println("sql is not executed");
  27. }
  28. }
  29. catch(Exception ex)
  30. {
  31. out.println(ex.toString());
  32.  
  33. }
  34.  
  35. %>
i have made proper connection with mysql-bin jar file.
one day before 1 prg of dbase was running but today
But its giving this error

java.sql.SQLException: Communication link failure: java.io.IOException, underlying cause: Unexpected end of input stream ** BEGIN NESTED EXCEPTION ** java.io.IOException MESSAGE: Unexpected end of input stream STACKTRACE: java.io.IOException: Unexpected end of input stream at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:1096) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:626) at com.mysql.jdbc.Connection.createNewIO(Connection.java:1562) at com.mysql.jdbc.Connection.(Connection.java:491) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at org.apache.jsp.insert_jsp._jspService(insert_jsp.java:63) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685) at java.lang.Thread.run(Unknown Source) ** END NESTED EXCEPTION **


If there is any problem with setting of Webapps folder.
plz help me any body.
Last edited by peter_budo : May 16th, 2008 at 5:10 am. Reason: Keep It Organized - please use [code] tags
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 199
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: problem with connecting jsp page with mysql

  #2  
May 16th, 2008
how often do we have to tell you kids to NOT do database access from 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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JSP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JSP Forum

All times are GMT -4. The time now is 12:06 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC