Home Answers Viewqa JSP-Interview-Questions How to display data fom MySQL DataBase-table in to JSP file by submitting a value in combobox.

 
 


lokeshreddy
How to display data fom MySQL DataBase-table in to JSP file by submitting a value in combobox.
1 Answer(s)      a year and 10 months ago
Posted in : JSP-Interview Questions

I have the same problem.plz help me.

I have MySQL DataBase/DB Name:lokesh;

Table Name:TR_list;

columns:nodename,packageno,TR; Values(crs,cs 4.0,xxx), Values(sdp,cs 5.0,yyy), Values(air,cs 6.0,zzz), i want to create a viewTR.jsp file in netbeans IDE, where i have to : 1.connect to DB in MYSQL and 2.TR List:input Text Box and button. 3.In the same viewTR.jsp file, i have to display the Nodename and packageno.

i.e.,select nodename,packageno from TR_list where TR='xxx';

Plz help me

View Answers

July 21, 2011 at 1:16 PM


1)select.jsp:

<%@page import="java.sql.*"%>
<html>
<head>
<script type="text/javascript">
function showEmp(id){ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null){
 alert ("Browser does not support HTTP Request")
 return
 }
var url="getvalue.jsp"
url=url+"?id="+id
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged(){ 
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
    var showdata = xmlHttp.responseText; 
    var strar = showdata.split(":");
      if(strar.length>1){
        var strname = strar[1];
        document.getElementById("name").value= strar[1];
        document.getElementById("address").value= strar[2];
        document.getElementById("email").value= strar[3];

         }
       } 
     }

function GetXmlHttpObject(){
var xmlHttp=null;
try{
 xmlHttp=new XMLHttpRequest();
 }
catch (e) {
 try {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}
</script>
</head>
<body>
<form name="employee">
<br><br>
<table border="0" width="400px" align="center" bgcolor="#CDFFFF">
<div id="mydiv"></div>
   <tr><td><b>Select Employee Name</b></td><td> 
   <select name="id" onchange="showEmp(this.value);">
      <option value="-1">Select</option> 

   <%
   Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select id from employee");
           while(rs.next()){
           %>
<option value="<%=rs.getString("id")%>"><%=rs.getString("id")%></option>
<%
           }
           %>

 </select>
</td></tr>
<tr><td ><b> Name:</b></td><td>
<input  type="text" name="name" id="name" value=""></td></tr>
<tr><td ><b> Address:</b></td><td>
<input  type="text" name="address" id="address" value=""></td></tr>
<tr><td><b> Email:</b></td><td>
<input  type="text" name="email" id="email" value=""></td></tr>

</table>
</form>    
<table border="0" width="100%" align="center">
<br>
<br>
</table>
</body>
</html>

2)getvalue.jsp:

<%@page import="java.sql.*"%>
<%
try{
String emp_id = request.getParameter("id").toString();
String data="";
Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
String query = "select * from employee where id='"+emp_id+"'";

ResultSet rs = st.executeQuery(query);
while(rs.next())
{
data = ":" +rs.getString("name") +":"+ rs.getString("address") +":"+  rs.getString("email");
}
out.println(data);
System.out.println(data);
}
catch (Exception e) {
e.printStackTrace();
}
%>

The above code will help you in solving your problem









Related Pages:
How to display data fom MySQL DataBase-table in to JSP file by submitting a value in combobox.
How to display data fom MySQL DataBase-table in to JSP file by submitting a value in combobox.   I have the same problem.plz help me. I have MySQL DataBase/DB Name:lokesh; Table Name:TR_list; columns:nodename,packageno,TR
How to display all the Select values from the MySQL database table in where condition= In JSP?
How to display all the Select values from the MySQL database table in where... to display all the select values from MySQL DB** only first value is displayed in the jsp file. @select * from table dept where dept_no=10;" jsp code i have used
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... to hyperlink. I want to use this data as hyperlink and use it as the value
dynamic retrivel of data from mysql database in table format at jsp
the data from database and display it as table format in jsp... For example, i have...dynamic retrivel of data from mysql database in table format at jsp  ... of A1 should be retrived from database and display it in the respective textbox
how to display data from jsp file into database
how to display data from jsp file into database  this is a jsp file...+",'"+email+"')"); out.println("Data is successfully inserted into database..."); con = (Connection)DriverManager.getConnection("jdbc:mysql://localhost
How to use next and previous button(or href) for database table that is retrieved from MySQL DB using jsp,jstl,javascript
How to use next and previous button(or href) for database table... to display previous 10records. Database Query like this: Select * from table_name where id=..; database:mysql technology:jsp,servlet,javascript,jstl  
Insert text into database table using JSP & jQuery
Insert text into database table using JSP & jQuery In this tutorial , the text is inserted into database table using JSP & jQuery. In the below example, the first JSP page is use to display text box in which we type data
combobox
stored combo box values from database. can u pls tell me the proceduer to get data from my sql database   Hi Friend, Try this: 1)ajax.jsp: <...combobox  In dashboar.jsp form, When i click employee id value
How to "Get data froom MySQL DB on giving a value in a tex-box in a JSP file."
How to "Get data froom MySQL DB on giving a value in a tex-box in a JSP file."  Hi, How to get data from MYSQL Database tables on giving a "text" in a text-box in a JSP file. Ex:dept table; if we give dept_no in a text-box in JSP
jsp combobox
jsp combobox  ihave three tables in database country,state and city..if i select one country throug combo box than other combobox show state only select country ...than city how i can implement through jsp   1
how to display data from mysql table in text box using jsp??
how to display data from mysql table in text box using jsp??  <p>hi, i have a written a code to display data from a mysql table into txtboxes... at line: 113 in the jsp file: /Cat1.jsp The local variable v_RGPC may not have
php csv file uploding into mysql database table.
php csv file uploding into mysql database table.  hai friends, i... fields. i have one mysql database table with two files fields, when ever i am uploding csv file, i want to fetch the datas in corresponding fields in table. can
Description of Database Table
Description of Database Table     ... about the database table. As we all know that, table has some specific information... by the database. By using a simple query we can get all information about the table
Inserting values in MySQL database table
insert values in the MySQL database table. We know that tables store data in rows... Inserting values in MySQL database table   ... the facility for inserting the values in MySQL database table. Description
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...;/html> this is my searchview2.jsp file where it display the result <...; <% String data=request.getParameter("bmi_value
Display Mysql "Blob" data using servlet
Display Mysql  "Blob" data using servlet In this section, we will discuss about how to display a blob data stored in database table. A Blob stores a binary large object in the database table's row. Blob object
how to retrieve data from database using combobox value without using request.getParameter in jsp - JSP-Servlet
how to retrieve data from database using combobox value without using request.getParameter in jsp  Answer pl
how to display values from database into table using jsp
how to display values from database into table using jsp  I want to display values from database into table based on condition in query, how to display that? For example i have some number of books in database but i want
Display Blob(Image) from Mysql table using JSP
Display Blob(Image) from Mysql table using JSP In this section, we will display blob data(image) from Mysql database table using JSP code. A Blob stores... : Insert Blob(Image) in Mysql table using JSP Download Source Code
how to insert the selected item of combobox in mysql - XML
successfully.alert box have to display only if data was stored in database otherwise...how to insert the selected item of combobox in mysql  hi, i have to insert the selected item from combobox into MYSQL database.pls provide
Make Unique Column in Database Table
Make Unique Column in Database Table   ... a unique key in a column of a database table. While declaring unique key...;} } Database Table: Student Table Stu_id Stu_name Stu_sub Stu
How to insert data from a combobox and textbox values into DB using JSP?
How to insert data from a combobox and textbox values into DB using JSP?  hi, How to insert a comb-box and a text box values in to DB using JSP? @DB:student; @table:stu_info; Combobox values:(class1,class2,class3); textbox1
Deleting Blob Data from Database table using servlet
Deleting Blob Data from Database table using servlet In this section, we will discuss about how to insert a blob data into a database table. A Blob stores a binary large object in the database table's row. Blob object
how to create database and table using jsp
how to create database and table using jsp  hi frnds...., i want to create database and table in mysql using jsp.... i have an registration form(name,sex,address,phone and so on ... ) i want to create individual table in mysql
How to use next and previous button(or href) for database table that is retrieved from MySQL DB.
How to use next and previous button(or href) for database table that is retrieved from MySQL DB.  Initially,display 7or10 records on a jsp pageand when click on the NEXT button(or href link) then display next 7 records
Insert Mysql Blob data
how to insert a blob data into a database table. A Blob stores a binary large object in the database table's row. Blob object contains a logical pointer... of the database table. Blob object  is valid for the duration of the transaction
Insert Blob(Image) in Mysql table using JSP
Insert Blob(Image) in Mysql table using JSP In this Section, we will insert blob data(image) in Mysql database table using JSP code. A Blob stores a binary... Blob(Image) in Mysql table using JSP Download Source Code
Navigation in a database table through jsp
Navigation in a database table through jsp       This is detailed jsp code that shows how.... Create a database:  Before run this jsp code first create a database named
MySQL Generate AlphaNumberic Id In JSP
the record from database table in JSP and display the record in specific format... how to generate id in specific format in MySQL and JSP. This example explains... numeric id using MySQL as database, tomcat 7 as a server for deploying the JSP
Combobox jsp from 0 to 10
Combobox jsp from 0 to 10  Hi guys please help me to write a very easy program using jsp to display value in combobox from 0 to 10. How to write...;% for(int i=0;i<=10;i++){ %> <option value="<%=i%>"><%=i%><
Inserting Image in Database Table
to the MySQL database table.  Flow of the process : This program helps the user to insert an image in the MySQL database table. To insert... Inserting Image in Database Table   
Deleting All Rows From the database Table
From the database Table      ... helps us to write on the browser. To delete all the rows from our database table... for deleting all the rows in the database table. This query will be fired
how to upload an image from a jsp page to a mysql database table using jsp
how to upload an image from a jsp page to a mysql database table using jsp  how to upload an image from a jsp page to a mysql database table using jspstrong text
combobox
combobox  i have three tables in database country,state and city... which inserted a value before country become erase \when selected country...plz... bgcolor="#CCFFFF"> <CENTER> <H1> <u>EDUCATIONAL DATABASE
combobox
combobox  i have three tables in database country,state and city... which inserted a value before country become erase \when selected country...plz... bgcolor="#CCFFFF"> <CENTER> <H1> <u>EDUCATIONAL DATABASE
Storing records of a file inside database table in java
Storing records of a file inside database table in java  Here is my requirement, I have a file which contains some number of records like... surya 25 4 3 ashok 27 I have to display a browse button
Export Database table to CSV File
Export Database table to CSV File In this tutorial, you will learn how to retrieve data from database and save it to CSV File. The Comma-separated values... as writing into a CSV file. Here is a database table is to be extracted: Example
Passing values in ComboBox from XML file
the data from the XML file and insert it into the ComboBox. To make a program over...Passing values in ComboBox from XML file In this tutorial we are going to know how we can pass a values in ComboBox by using XML.  This example
Servlet to add the data into database
the data in the database table from a html form.  This servlet program... Servlet to add the data into database   ....  The data can be inserted in the database that reacquired connection
Retrieving All Rows from a Database Table
MySQL database and java file so that the we can retrieve all data from... from a database table. You know that table contains the data in rows and columns...: Above code retrieves all data from specific database table. getInt(String column
JTable Display Data From MySQL Database
JTable Display Data From MySQL Database In this section we will discuss about how to display data of a database table into javax.swing.JTable This section will describe you the displaying of data of a database table into a JTable
Update Database Table using JDBC in JSP
Update Database Table using JDBC in JSP... the existing  record of mysql table using jdbc connectivity in the jsp page...;/html> After submitting the name, it will be updated in the database
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
Sum of Column in a Database Table
of specific column data in the database table. Consider an example of any... Sum of Column in a Database Table   ... is to establish the connection with MySQL database by using the JDBC driver
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  Hi Friends, When i click combobox value in jsp form page, it will diplay... click combobox the related student name did not display... On friend gave
jsp page submitting
jsp page submitting  whenever i am submitting the jsp page it downloads some unknown file on tomcat server
Arrange a Column of Database Table
with MySQL database. As soon as the connection gets established it takes a table... Arrange a Column of Database Table   ... that arrange the records of database table in descending order. The descending
How to read and display data from a .properties file from a jsp page
How to read and display data from a .properties file from a jsp page  I have a .properties file. I have to create a jsp page such that it reads the data from this .properties file and display it in table format. Ex:by using
Delete a Specific Row from a Database Table
of a specific database table.   '1': This is the value of specified column... Delete a Specific Row from a Database Table   ... from a specific database table. Here is an example with code which provides
Display Data from Database in JSP
, to show data from the database click on the link that calls another .jsp file named...;To display all the data from the table click here...</h2></TD>...;title>display data from the table using jsp</title> </head> <

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.