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



Home Answers Viewqa JDBC Help on JSP and JDBC
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Manoj Kumar Singh
Help on JSP and JDBC
2 Answer(s)      6 years and 6 months ago
Posted in : JDBC


Retrieve data from Database in JSP and JDBC connection.


Advertisement
View Answers

April 2, 2008 at 8:51 PM


retrivedata.jsp

<%@ page language="java" import="java.sql.*,java.util.*,java.text.*" %>
<html>
<head>
<title>Retrive value from database</title>
</head>
<body>
<table border="0" width="50%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<h2><font color="#FF0033">Retrive data from database</font></h2>
<form method="POST" >
<table border="1" width="50%" cellspacing="0" cellpadding="0" bgcolor="#66FFCC">
<tr>
<td width="50%" valign="right"><b>ID</b></td>
<td width="50%" valign="right"><b>Employee Name</b></td>
<td width="50%" valign="right"><b>Position</b></td>
<%
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";;
String db = "register";
String driver = "com.mysql.jdbc.Driver";
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,"root","root");
try{
Statement st = con.createStatement();
String query = "SELECT * FROM emp_details";
ResultSet rs = st.executeQuery(query);
while (rs.next()) {
%>

<tr>
<td width="50%" valign="right"><%=rs.getInt("empno")%></td>
<td width="50%" valign="right"><%=rs.getString("empname")%><br/></td>
<td width="50%" valign="right"><%=rs.getString("job")%><br/></td>
</tr>
<%
}
rs.close();
con.close();
}
catch(SQLException ex){
System.out.println("SQL statement is not executed!");
}
}
catch (Exception e){
e.printStackTrace();
}
%>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>


April 8, 2008 at 4:04 PM


hi friend,
jsp only for view , we should use for presentation don t combine databse code and jsp, it is not good approach,use separate class for connection from that class get values.

jsp only for view , even html designers can do this, we are java programmers keep mind


Related Tutorials/Questions & Answers:
Help on JSP and JDBC - JDBC
Help on JSP and JDBC  Retrieve data from Database in JSP and JDBC...;% Connection con = null; String url = "jdbc:mysql://localhost:3306/"...;hi friend, jsp only for view , we should use for presentation don t
Help on JSP - JDBC
Help on JSP  Sir I am makeing a project name Online reservation and Enquiry system. I had completed the front end design with the help of html,delete and search the database from the html file with the help of JSP.  hi
Advertisements
Jsp,JDBC - JDBC
Jsp,JDBC  Write a Program using Servlet,JSP, JDBC and XML to create a web application for a courier company to provide an online help in tracking the delivery status of items.  Hi friend, For solving the problem
JDBC in JSP - JDBC
JDBC in JSP  Sir, I got a problem in my jsp page which contains... happening for my update query. Please help me with a suitable suggeastion. Regards Sreejith  send me your jsp coding then i can understand what
JDBC with JSP
JDBC with JSP  how to get a combo box value and pass it to the java method in a jsp program dynamically, without moving to servlet or next page
JSP help
JSP help  Hi i am using jsp,html and mysql. I am displaying one question & their 4 options per page. For that i have one label for question &... do this? Please Help
jsp help
jsp help  Hi i am doing my project in jsp.using netbeans 6 and mysql 5.0. and i managed to complete it. and now its submission time. but am confused... with it. so that my project can run independently in any server. plz help me. am so
Help on JDBC and my SQL 5 database - JDBC
Help on JDBC and my SQL 5 database  Dear Sir, I had create a statement for the JDBC as shown below: try... the connection c = DriverManager.getConnection ("jdbc:mysql
jdbc,jsp - JDBC
jdbc,jsp   this is my jsp code in this code i have to give hyperlink to database(selected row must be deplay)  Hi keerthi, replace the line
JDBC in JSP - JDBC
JDBC in JSP   Sir, This is the code showing the problem. regards sreejith
JDBC in JSP - JDBC
JDBC in JSP   Sir, This is the code showing the problem. regards sreejith
jsp - JDBC
jsp  My code is not working please anyone help me to store retrieved... variable. JSP Page... Login Successful <%-- <jsp:forward page="studenthome.jsp"/>
jsp-jdbc - JDBC
jsp-jdbc  Hi! html- jsp-jdbc program from the html form where... jsp frequently. I am getting error through request.getParameter(). can you please...="DriverManager.getConnection("jdbc:odbc:ashokdb","scott","tiger"); Statement st
jsp - JDBC
JSP Storing Data, Datatype vale in SQL   Storing Data, Datatype vale...;<%Connection con = null; String url = "jdbc:mysql://localhost:3306..., will help you in storing date in sql database.See how to insert data from html
jsp - JDBC
jsp  I have one jsp code.but it is included oracle databse...("oracle.jdbc.driver.OracleDriver"); Connection con = DriverManager.getConnection("jdbc:oracle... = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:oracle","scott","tiger"); I
JSP - JDBC
JSP Store Results in Integer Format  JSP Example Code that stores the result in integer format in JSP  Hi! Just run the given JSP Example...;/b></td><% Connection con = null; String url = "jdbc:mysql
jsp - JDBC
jsp  -------------------------------------------------------------------------------- how to receive data into jsp from html for dropdown boxes
urgent help needed in JDBC AND JAVA GUI - JDBC
urgent help needed in JDBC AND JAVA GUI  my application allows... want any one to help me convert from scanner to java GUI for this code...(); } } // thanks for any help rendered   Hi Friend, Try the following code
jsp - JDBC
jsp  i am doing project in java using jsp as font end and microsoft access as back end my project airline ticketing reservations how can i give hyperlink to database rows in jsp code.   First
jsp - JDBC
jsp  how to link jsp code with next htmlcode.  Hi keerthi, Can u explain ur question clearly? What is your exact Requirement
jsp help - JSP-Servlet
jsp help  hai friends i am using videos,which will play on my webpage using flowplayer.my doubt is where will i store my videos whether in the database or in another local folder. please help me as soon as possible thanks
jsp - JDBC
about update at http://www.roseindia.net/jsp/implement-javascript
jsp - JDBC
: Unable to compile class for JSP An error occurred at line: 20 in the jsp file...\localhost\Airlines-Project\org\apache\jsp\Flightdetails_jsp.java:69: cannot find symbol symbol : variable src location: class org.apache.jsp.Flightdetails_jsp
jdbc-jsp
jdbc-jsp  <html> <head> <title>your info mail</title> </head> <body bgcolor=#FAEBD7> <center><u>... = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root
JSP and JDBC - JSP-Servlet
JSP and JDBC  Respected sir/Madam, I am R.Ragavendran.. I... for JDBC codings must be present.. NOTE: When User clicks Insert,for example...; IF I GET THIS HELP IN TIME.... Thanks/Regards, R.Ragavendran.
JSP-Servlets-JDBC
be JSP-->Servlet-->JDBC-->Services-->JSP 3, Update - The table created... if we give the form ID in a JSP and submit delete. Please help me...JSP-Servlets-JDBC  Hi all, 1, Create - i want sample code
jsp help - JSP-Servlet
jsp help  i want to add n remove rows dynamically and also want to add data in database in jsp ....  Hi Friend, Try the following code: 1)table.jsp: Add/Remove dynamic rows in HTML table function
jsp help - JSP-Servlet
jsp help  In below code value got in text box using 'ID' Attribute ... I want to use that value in query to fetch related values in same page...://www.roseindia.net/jsp/comboSelect.shtml Thanks
jsp help - JSP-Servlet
jsp help  i got below code for dynamically add n delete row... but in my table there are 17 colum in 1 row..i want to add whole row with 17 cloum.. so which changes are required??? 1)table.jsp: Add/Remove dynamic
Query regarding JSP, JDBC
Query regarding JSP, JDBC  can I get the code for the question asked by me regarding JSP,JDBC
Programming in JDBC and JSP - JSP-Servlet
Programming in JDBC and JSP  Write a program using JDBC and JSP to display the names and addresses of all those MCA students at your study centre... Semester.   Hi friend, Code to help in solving the problem
 

 

 

DMCA.com