Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Development-process Problem in Jsp and database

Have Programming Question? Ask it here!
 
 
 


Rajendra
Problem in Jsp and database
2 Answer(s)      5 years ago
Posted in : Development process



Advertisement
View Answers

April 18, 2009 at 11:34 AM


Hi Friend,

You can use the following code:

step1) Create databaseTable.jsp:

<%@ page import="java.sql.*" %>
<html>
<head>
<title>display data from the table using jsp</title>
</head>
<body>
<FORM ACTION="insert.jsp" method="get" >
<%
try {
String connectionURL = "jdbc:mysql://localhost:3306/register";;
Connection connection = null;
Statement statement = null;
ResultSet rs = null;

Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "root", "root");
statement = connection.createStatement();
String QueryString = "SELECT * from registertable where user_id=1";
rs = statement.executeQuery(QueryString);
%>
<TABLE cellpadding="15" border="1" style="background-color: #ffffcc;">
<%
while (rs.next()) {
%>
<TR><TD>First Name: </TD><TD><input name="text2" type="text" value="<%=rs.getString(2)%>"></TD></TR>
<TR><TD>Last Name: </TD><TD><input name="text3" type="text" value="<%=rs.getString(3)%>"></TD></TR>
<TR><TD>Address: </TD><TD><input name="text4" type="text" value="<%=rs.getString(4)%>"></TD></TR>
<TR><TD>Email: </TD><TD><input name="text5" type="text" value="<%=rs.getString(5)%>"></TD></TR>
<% } %>
<%
rs.close();
statement.close();
connection.close();
} catch (Exception ex) {
out.println(ex);
} %>
</TABLE>
<input type="submit" value="Update">
</Form>
</body>
</html>


April 18, 2009 at 11:35 AM


cont...........

step2) create insert.jsp:

<%@ page import="java.sql.*" %>
<%
String text2=request.getParameter("text2");
String text3=request.getParameter("text3");
String text4=request.getParameter("text4");
String text5=request.getParameter("text5");
try {
String connectionURL = "jdbc:mysql://localhost:3306/register";;
Connection connection = null;
Statement statement = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();

connection = DriverManager.getConnection(connectionURL, "root", "root");

statement = connection.createStatement();
int val = statement.executeUpdate("update registertable set firstName='"+text2+"',lastName='"+text3+"' ,address='"+text4+"',email='"+text5+"' where user_id=1");
statement.close();
connection.close();
}
catch(Exception e){
out.println(e);
}
%>

Thanks


Related Tutorials/Questions & Answers:
Problem in Jsp and database - Development process
Problem in Jsp and database  Hi, How can I reterive values from database and display them in teextboxes so that when the user select the UPDATE... to the database itself . Thanks in advance.  Hi Friend, You can use
database problem
database problem  I did connect my jsp page to database and it showed the result on another jsp page but i want to show the data of that field on which i click to mouse from the jsp page where all the data field has been showed
Advertisements
database problem
database problem  I did connect my jsp page to database and it showed the result on another jsp page but i want to show the data of that field on which i click to mouse from the jsp page where all the data field has been showed
Facing Problem to insert Multiple Array values in database - JSP-Servlet
Facing Problem to insert Multiple Array values in database  Hai friend , Iam beginner in jsp and creating the project in shopping cart but ihave facing the problem while inserting the data in database. iam using the MsAccess
problem in database
problem in database   thanks for web site. I want change this code to insert data into PostgreSql database using jsp,servlets. but i getting...){ out.println("Couldn't load database driver: " + e.getMessage()); } catch
problem from registering a data in database with servlet - JSP-Servlet
problem from registering a data in database with servlet  Hi Rose, i created a servlet to validates ten user details in the database, if present... the user's details and submit into database. but it'll first insert the details
Jsp problem
Jsp problem  Hello friends.I want to share my jsp problem.I want to show all of my database(mysql) tables except two(user,manufacturer) in a jsp page.plssss help me
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want... name also is given by the user.My database is in mysql.Plsssss help me... Thanks..." action="http://localhost:8080/examples/jsp/insertdata.jsp"> <table> <
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want... name also is given by the user.My database is in mysql.Plsssss help me... Thanks..." action="http://localhost:8080/examples/jsp/insertdata.jsp"> <table> <
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want... name also is given by the user.My database is in mysql.Plsssss help me... Thanks..." action="http://localhost:8080/examples/jsp/insertdata.jsp"> <table> <
jsp problem
jsp problem  problem:::::::: On JSP form ,when i insert data in text field........at that time action is perform and data is retriev from data base and get assign to other field on that form........ when data is assign to other
jsp problem - JSP-Servlet
jsp problem  here is a code for Retrieving image from mysql database through jsp. but i cann't set size of image when it was display so what should i do?? when the image retrieve from the database i want to set its size to how
jsp problem - JSP-Servlet
jsp problem  here is a code for Retrieving image from mysql database through jsp. but i cann't set size of image when it was display so what should i do?? when the image retrieve from the database i want to set its size to how
jsp problem
jsp problem  Hello Friends, I want to show one page for 5 seconds and after that i want to redirect the page to another URL
jsp problem
jsp problem  Hi every one plz give me answer for below question ASAP I created one JSP(used pre defined javascript in jsp to get rtf format in browser) which creats RTF Format in browser to enter data. MY question is after i
JSP Problem - JSP-Servlet
JSP Problem  Hi, I have problem,this is my senario I have one jsp,this jsp having the 3 fields.let me take 3fields userName,emailAddress... please do the needful   hi friend, form Insert into database
Oracle 9i database problem
Oracle 9i database problem  Hi Somebody has given the solution but i.............,send reply immediately. I have a problem in Oracle9i .I have installed... what i created .But after closing the SQL+ ,the problem started.When i again opened
Database problem - WebSevices
simple database connectivity code. if you have any problem then send me detail...Database problem  Hello, How i connect my database file& tables to Zend library file. In which library file i should change that code
problem in jsp programming - JSP-Servlet
problem in jsp programming  Write a JSP program which displays a webpage containing arrival of new items within a particular month in the different... in solving the problem : Connection with mysql database
Database fetching problem
Database fetching problem  I have multiple database table and want to get all records in one object how can i do this.Pls guide
database connectivity problem
database connectivity problem  what if client dont have database with them then what is other way to run successfully our programm   Please visit the following link: http://www.roseindia.net/jdbc
Problem in accessing data from Database
Problem in accessing data from Database  hi..... i'm making a project on servlet and jsp with ms access 2007 at the backend. One field in my database... someone plz help me out with this problem
database problem - JDBC
database problem  I installed Oracle 8.05 on Redhat 6.1 linux. If i fire up SQl plus seesion from the localhost, i can login succsfully as any user, If i go to a win98 or NT machine, I will get the following error after trying
jsp code problem - JSP-Servlet
jsp code problem  Hi, I have employee details form in jsp. After validate all the fields, it will update the database, then move to next form. I have a problem with open the next form. plz, help me. thanks,  Hi
jsp problem - JSP-Servlet
jsp problem  hi, i am working on a project of developing a shopping cart for online book store.can it be done using jsp?if yes, can u please help me doing so?  Hi Friend, Please visit the following link: http
jsp database
jsp database   I want to retrive value in my jsp page but i dont want show my database query in my jsp page. is there any other method to show value in my jsp page using java class
problem in programming - JSP-Servlet
problem in programming  Hi! I am new with jsp. I am facing a problem in programming to calculate the time interval between login time and logout time of user
jsp image problem - JSP-Servlet
jsp image problem  hi everyone, How to display multiple images from mysql database to jsp page. please help me
coding problem - JSP-Servlet
coding problem  dear sir i m very new to JSP sir i m getting problem in dynamically changing the option of combobox from database(ms acess... that record from the database where asian paints found and other combobox dynamically
Problem in inserting clob data in jsp
Problem in inserting clob data in jsp  how to insert any rich text editor data (which have more than 32766 characters) in a clob type column of oracle database with jsp
coding problem - JSP-Servlet
coding problem  dear sir will u plz tell me how can we delete a record from the database(MSaccess) when option in the combobox is selected(jsp)  If u want to delete the record from database, by seleting
problem in setting the values from database
problem in setting the values from database  hello friends, can anyone help me?? I am facing this problem for past one week. I could't set the values from database. here is the code: private JTextField getJTextField1
Session Problem in JSP - JSP-Servlet
Session Problem in JSP  I have developed a online feedback form in JSP platform. I have created normal session in JSP page. It is running in my... normally from Remote machine by only writing JSP code.  Hi friend
Problem in uploading image to to mysql database
Problem in uploading image to to mysql database  Hi, need some help... be save in the database. and the image will also save in the desired folder. i have no problem in saving the image in the folder, my problem is it can't save
Problem in uploading image to to mysql database
Problem in uploading image to to mysql database  Hi, need some help... be save in the database. and the image will also save in the desired folder. i have no problem in saving the image in the folder, my problem is it can't save
jsp usebean problem - Struts
popupwindow jsp below code run.. ...here iam getting the problem..in the below...jsp usebean problem   --Select... jsp
coding problem - JSP-Servlet
coding problem  Dear sir i m very new to JSP .I am using two... the database should be displayed in other combobox, means how can we refresh... to get the data from the database without refreshing the page. use 'onchange
logout problem?? - JSP-Servlet
logout problem??  sir, the logout code which u have send is not the proper solution coz,by using this code the browser get closed which shuold.../Logout.shtml http://www.roseindia.net/jsp/loginstatus.shtml Thanks
logout problem.. - JSP-Servlet
logout problem..  hi... first of all thanks for ur... but their is some problem with the the logout,i m not able to logout when... done in the code i have used session object in project's servlet and jsp
Radio Button Problem in jsp.
Radio Button Problem in jsp.  I have a small doubt in my application... for each row as i got data from the database using iterator tag,but when i... radio button values from jsp to action using javascript
jsp reload current page problem
jsp reload current page problem  Hi, i am facing problem while reloading the JSP page
jsp reload current page problem
jsp reload current page problem  Hi, i am facing problem while reloading the JSP page
Array problem - JSP-Servlet
Array problem  Respected Sir/Madam, I am having a pop up window in which the database values are available.. Its in the format of: One..... Bur my problem is that if the pop up window contains only 1 record
JSP run problem
JSP run problem  type Exception report message description... this request. exception org.apache.jasper.JasperException: Exception in JSP...) root cause java.lang.NullPointerException org.apache.jsp.bb_jsp
Java Problem - JSP-Servlet
Java Problem  How to run a Simple JSP program ? what steps... the webapps folder of apache tomcat. 5)Create a jsp file 'hello.jsp'.You can put your jsp file either inside the web application folder along with WEB-INF or you
tomcat problem - JSP-Servlet
perfectly. Kindly let me know what is the problem at an earliest. Thanking... found your problem.. http://www.roseindia.net/web-application-server/tomcat
jsp code problem - Java Beginners
jsp code problem  Hi, I have a problem with else part. It did not show the message box when the result set is null. plz, help me. thank u..."); regards, sakthi   Hi friend, You want if no record in database
arraylist problem - JSP-Servlet
my code once again only in which i m facing the problem. /* * To change... entered in database. but its showing only one row. but in console its showing... correctly from database but not showing in frontend plz plz help me out 
JSP code problem - JSP-Servlet
JSP code problem  Hi friends, I used the following code...: <% //to get the content type information from JSP... of: Please can somebody rectify this problem........  
Servlet Problem - JSP-Servlet
Servlet Problem  Hii I am Ajay . I am makin g a project in java using servlets. I have a database in which I have stored images along with some other info(Name, address type). I want to display that info in text form along
Advertisements
 

 

 

DMCA.com