Home Answers Viewqa Java-Beginners Search data from database

 
 


Ragini Shukla
Search data from database
2 Answer(s)      4 years and 11 months ago
Posted in : Java Beginners

View Answers

August 11, 2008 at 5:32 PM


hai frnd...i'm prashob not deepak....
i think u r working with jsp....
then on clicking this search and delete(both shpould be submit type) forward it to a new jsp page,
then

//this is initialization
<%@ page import="java.sql.*" %>
<%! Connection con;
ResultSet rst;
Statement st;
String url="jdbc:db2://url/db:"; //this is the url to ur database

%>
//this is class loading.here i used type4 driver for ibm db2.change according to ur db.

<%
try
{
Class.forName("com.ibm.db2.jcc.DB2Driver");
con=DriverManager.getConnection(url,"user","pwd");
System.out.println("After Establishing connection");
}
catch(ClassNotFoundException e)
{
System.out.println("ERROR!1: "+e);

}
%>


//create table

<table>
<tr><td>NAME</td><td>last name</td></tr> //this is table header


//i assume ur table name as "table" and the column name as name.and this table's first column as name and second column as last name

<%
try
{

st=con.createStatement();
rst=st.executeQuery("select * from table where name='"+request.getAttribute("name")+"' order by 1");
System.out.println("After select");
while(rst.next())
{
System.out.println("inside while");%>
//the following statement is for displaying the names.
<tr>
<td> <%= rst.getString(1) %></td>
<td> <%= rst.getString(2) %></td>
</tr>


<%} }

System.out.println("After reading values");

}

catch(Exception e)
{
System.out.println("ERROR!!2 :"+e);

}


%>


</table>

this is the case for displaying names on a page..
if u want to delete ,then find out which submit button is pressed in the previous page,
then according to that,
use the sql command as delete * from table where name "the value passed from the previous page..
i mean request.getParameter("name");

hope it would help u....
for further needs ...get me at prashobvee@gmail.com

thanks and regards
prashu...





August 11, 2008 at 5:45 PM



hai,
the above code assumes u have only two columns in the table.....if u have many columns in the table,i mean u have many datafields to be displayed add in the while loop and html table definition also....
this displayes all the users with same name.....because there may be many persons having same ..u didnt tell this name is a unique value..



thanks and reg..
prashu









Related Pages:
search
search  how to develop search box and how to retrive data from database..   Please visit the following link: Search box
Search data from database - Java Beginners
Search data from database  Hi Deepak, This is not correct code... to user name. (means search all field from database and display using... with two button search and delete. 2:- User input name(with alphabetical
how to display data from database according to entered value in search field
how to display data from database according to entered value in search...(); System.out.println("Disconnected from database"); } catch (Exception e...; <input type="submit" name="submit" value="Search">
search from database
search from database  DBUtil util = new DBUtil(); try { JOptionPane.showMessageDialog(null, "Connection Opened!"); Connection con...); }   i want to retrieve values from database and display them in my
Code for search data - Development process
Code for search data  Hi, can u give me jsp code for search data. When i select any 1 from 3, it has to display all d corresponding data from database sub-combo box in this code is not working. Search Page
retrieve data from mysql database
retrieve data from mysql database  hi am not familiar in php.....even... selected value on combobox which is to be retrieve the relevant data from mysql database using php.... below my code is that.. <html> <head>
Search from Database In Servlet
Search from Database In Servlet   ... data from database on the browser.  Step 1: Create a web page... on the "Search" button.  Search.java retrieves data from
search functionality using jsp from database
search functionality using jsp from database  search functionality using jsp from database
AJAX Search
using PHP and MYSQL as the database. Can somebody please suggest me the AJAX...("autosuggest.php", {queryString: ""+inputString+""}, function(data...(); $('#suggestionsList').html(data); $('#country
selecting data from database
selecting data from database  how to select data from database using Dao in struts   Hi, You have to load the data from database using hibernate and send the data in a Java file object to jsp page. Please read at http
retrive data from database
retrive data from database   hi.. i made a application form. it's have attribute s.no,name,roll no and i enter a few records. now i want to view all record not in database access sheet i want to view it at any another
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want to insert data into database and also want to display the things i have entered..."')"); ResultSet rs = stmt.executeQuery( "SELECT * FROM data"); String id
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want to insert data into database and also want to display the things i have entered..."')"); ResultSet rs = stmt.executeQuery( "SELECT * FROM data"); String id
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want to insert data into database and also want to display the things i have entered..."')"); ResultSet rs = stmt.executeQuery( "SELECT * FROM data"); String id
database
database  how to search data from database using jsp & how to rank the searched result using any searching algorithm   Please visit the following links: http://www.roseindia.net/jsp/user-search.shtml http
searching from database
searching from database  how to search data from data base throug search...such as contact no./lastname /firstname should give whole information from database...   Please visit the following link: Servlet search
retrive data from database?
retrive data from database?  hellow i have a database sheet name as db1. it's contain sixty(60) sn,name ,rollno(primary key),father's name etc... from db1 and enter value in text box according there name,rollno and save
Populate a combo box using data from a database
Populate a combo box using data from a database  Hi Guys, In need... to populate the first one, and then how to send the data off to a servlet and preform a search on the database for the values I want, but then how do I pass that back
SEARCHING THE DATA FROM DATABASE AND DISPLAY THE SEARCHED DATA IN HTML PAGE
SEARCHING THE DATA FROM DATABASE AND DISPLAY THE SEARCHED DATA IN HTML PAGE  pls help me....in this i want to search books from the database... the user specified $data = mysql_query("SELECT * FROM book WHERE upper($field
database
user required data from the database and rank the results and display... that) based on that system search it to the database and rank the results and retrieve...database  i need optimised search algorithm and ranking algorithm
Data needs to be gathered in XML file from the database (MySql) using JSP
Data needs to be gathered in XML file from the database (MySql) using JSP ... data regarding particular id from the database table. Data needs to be gathered in XML file from the database (MySql) using appropriate JSP/Java Bean functions
fetch data from database in javascript
fetch data from database in javascript   How to fetch data from database in JavaScript when it is a leap year
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to get the data from database - Java Server Faces Questions
how to get the data from database  In database i have created some tables(person details) and i have one jsf page in that one search button is there if i enter first 3 digits of a name and click on the search button it should
How to show multiple identicle rows from database on clicking search button to jtable
); } } }); } }   Here is a code that search the data from the database and show multiple identical rows from database on clicking search button...How to show multiple identicle rows from database on clicking search button
How to show multiple identicle rows from database on clicking search button to jtable
); } } }); } }   Here is a code that search the data from the database and show multiple identical rows from database on clicking search button...How to show multiple identicle rows from database on clicking search button
How to show multiple identicle rows from database on clicking search button to jtable
); } } }); } }   Here is a code that search the data from the database and show multiple identical rows from database on clicking search button...How to show multiple identicle rows from database on clicking search button
datagrid search - Hibernate
;Hi Friend, Do you want to get sorted data from the database along...datagrid search  Hi friend, i have displayed a datagrid using jsp but i need a search option in that which is used to display and sort
Retrieve The Data From MySql Datbase
Retrieve The Data From MySql Datbase   How to Retrieve The Data From MYSQL database TO Use Select the Emp_id Option.And Also Search Option
How to search the table name in MS SQL Database 2005 from application
How to search the table name in MS SQL Database 2005 from application  How to search the table name in MS SQL Database 2005 from application from our helpdesk application? application might be in html
delete data from database - SQL
delete data from database  HOw to delete specific data from table> I want to delete one record from database. Thnx  Hi friend, -------------------------------------------- Visit for more information
Search Engine Interface
Search will search the data from Lucene Index and display on the page as shown below...; button. Application will add the data into database as well as Lucene index... Search Engine Interface   
To retrive data from database - Struts
To retrive data from database  How to get values ,when i select a select box in jsp and has to get values in textbox automatically from database? eg... come to jsp page automatically from database
use data from database table as hyperlink value - JSP-Servlet
use data from database table as hyperlink value  I'm creating a web page that allows user to search my database. The page will display partial results of my database, then the first column of the resultset was converted
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 is text and all others are of currency data type. If i enter 0 or null value
Displaying file from database
that corresponding file from database. I have list of file id related to search. I want...Displaying file from database  I have list of files in my database. I... strQuery = "select file_data from file where id="+id; ResultSet rs
retrieve data from database with hyperlink
retrieve data from database with hyperlink  sir....i have one table called 'name' having two values i have to retrieve those data with a hyperlink and show in browser and if we click hyperlink its shows his sub categories....how
JSP Search Example code
the data from database. In this example we will search the book from database... JSP Search - Search Book Example       Search Book Example In this tutorial we
retreive integer data from database
retreive integer data from database  i made a table named result...=lalit&database=mydb"); String url="select marks from student where rollno... and two buttons "ok" and "cancel" i want to take input from textfield
Getting Textbox data from database
data from database and display it on the textboxes. <%@page language="java...Getting Textbox data from database  When i m trying to get data in textbox as readonly from database i m getting following error.and my code is shown
MySQL PHP Search
; MySQL Search is used to search and return a records from a table... The Tutorial illustrate an example from 'MySQL PHP Search'. To understand... | +-------+---------+--------+ 10 rows in set (0.00 sec) Searching data from
GWT -- retrive the data from Database
GWT -- retrive the data from Database  the user can create an event. In the create page, we have three buttons. Save as draft, preview and save... button, you have to create a dynamic jsp which should read the contents from
Getting Textbox data from database
;Here is a jsp code that retrieves data from database and display...Getting Textbox data from database  When i m trying to get data in textbox as readonly from database i m getting following error.and my code is shown
Data retrieve from mysql database
Data retrieve from mysql database  Hi sir, please give some example of jsp code for retrieving mysql database values in multiple dropdown list... from the dropdown, related data will get displayed on the textboxes. Here we have
Html code for search - Development process
if you want to use HTML code with JSP and Servlet to search from database...Html code for search   Hi, when i click search button .It has to display table with data. I have completed design only. Plz give code
Search Engine
Search Engine  I have gone through the below mentioned link document to create search engine and fetch the data from mysql database.But i am getting errors. http://www.roseindia.net/sql/mysql-table/sql-search.shtml Error: Notice
how to search a word on entire database? - SQL
how to search a word on entire database?  hi, I want to search a word into the entire database.. note: not from particular table.. using php and mysql. any way to find this? thanks in advance