| | |
mysql+jsp
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2008
Posts: 9
Reputation:
Solved Threads: 0
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.................;
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.................;
JSP Syntax (Toggle Plain Text)
<%@ page import="javax.servlet.*" %> <%@ page import="javax.servlet.http.*" %> <%@ page import="java.io.*" %> <%@ page import="java.sql.*" %> <% String vemp_code=request.getParameter("emp_code"); String vemp_name=request.getParameter("emp_name"); Connection conn = null; ResultSet rs=null; String url = "jdbc:mysql://localhost:3306/"; String driverName = "com.mysql.jdbc.Driver"; String userName = "roor"; String password = "root"; try{ Class.forName(driverName).newInstance(); conn = DriverManager.getConnection("jdbc:mysql://localhost/niree",userName,password); Statement stmt = conn.createStatement(); stmt.executeUpdate("use newuser;"); out.println(" connection is established"); //Statement stmt = conn.createStatement(); //int val = //stmt.executeUpdate("INSERT employe VALUES(?,?)"); PreparedStatement pst; pst=conn.prepareStatement(" insert into employe values(?,?)"); pst.setString(1,vemp_code); pst.setString(2,vemp_name); } catch(Exception e){ System.out.println("error occured"); e.printStackTrace(); } %>
Last edited by peter_budo; Apr 4th, 2008 at 3:12 pm. Reason: Keep It Organized - please use [code] tags
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?
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.
#
String userName = "roor";
#
String password = "root";
i think you should take care of Name
check it plase it should be ROOT not ROOR
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.
002-010 4411 540
Admin@ErpEgypt.com
Internet Marketing Consultant - Sales and Marketing Certified.
![]() |
Similar Threads
- How to Connect MySQL from JSP Page (JSP)
- how to update database using mysql and jsp (JSP)
- Inserting uft8 strings into MySQL from jsp page (JSP)
- Cant get a free web host for JSP & MYSQL (JSP)
- Problem connecting my Tomcat Server and MySQL using JSP (JSP)
Other Threads in the JSP Forum
- Previous Thread: Jsp doesnt work while source code of it that runned from Html does Work perfect. Why?
- Next Thread: Window close event in safari
| 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







and, this line is missing