query problem

query problem

how write query in jsp based on mysql table field?

i have employee table it contain designation field, how write query in jsp like

   select Ename from employee where Designation="Marketing Manager";

how to write this query in jsp please anybody help me, and send me that code urgently if it possible to write in jsp?

thanks

View Answers

September 6, 2012 at 4:11 PM

Here is a jsp code that displays the employee names from the database table who are Marketing Managers.

<%@page language="java"%>
<%@page import="java.sql.*"%>

<table border="1">

<%
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
String query = "select Ename from employee where Designation='Marketing Manager'";
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
while(rs.next()){
%>
<tr>
<td><input type="text" name="name" value="<%=rs.getString("name")%>"></td>
</tr>
<%
}
}
catch(Exception e){}
%>
</table>









Related Tutorials/Questions & Answers:
query problem
query problem  how write query in jsp based on mysql table field? i have employee table it contain designation field, how write query in jsp... to write this query in jsp please anybody help me, and send me that code
delete query problem - Hibernate
correctly , the problem is only delete query. 2) query.executeUpate(); ->...delete query problem  SessionFactory fact = new Configuration...'"; Query query = sess.createQuery(hql) query.executeUpate(); // int row
Advertisements
Problem in executing query....
Problem in executing query....  Suppose there is a textbox or a text... this data with request.getParameter() but when I execute the query to store in oracle it is showing error because of the '.I understand where the problem is.If
Problem in updating query in Hibernate - Hibernate
Problem in updating query in Hibernate  Hi, I have used a query to update the existing columns of one table. The query updates the records in the main table but it does not update the tables that are mapped from the main table
problem in insert query - JSP-Servlet
problem in insert query  Hi! I am using this statement for data...   Hi friend, We check your Query it is correct .If you have problem plz give full details with source code and visit to : http
select Query result display problem
select Query result display problem  Hi, String SQL_QUERY ="from Cc"; Query query = session.createQuery(SQL_QUERY); for(Iterator it=query.iterate...]); } when I am executing the above query the following error will happend
MS-ACCESS Query Problem - SQL
MS-ACCESS Query Problem  hi sir i have table which is initially... tables Course and Class wise Ex..Query like: if we execute this Query... records so these all records i want to insert into Deleted Table plz can u give Query
i have problem with this query... please tell me the resolution if this .........
i have problem with this query... please tell me the resolution if this .........  select length(ename)||' charecters exist in '||initcap(ename)||'s name' as "names and length" from emp
i have problem with this query... please tell me the resolution if this .........
i have problem with this query... please tell me the resolution if this .........  select initcap(ename),job from emp where substr(job,4,length(job,4,3)))='age
problem on php
problem on php   l have five tables and build them as forms and link between them php and database and i want to build query between them plz help me soon   PHP MySQL Tutorials
php problem
php problem  Hello!! I have a problem ,i want to display the data of a single row in my database,this is the code: <?php</p> include....'" LIMIT 1'; $result = mysql_query( $sql); if(! $result) { die('Could
problem in onlinetest...
problem in onlinetest...  hi, my code getting the problem is ,when user leave a question then the server puts error... pls help me
Problem with Hibernate or 11g
Problem with Hibernate or 11g  Hi I am using Hibernate and 11g in my project. The problem I am facing is I am executing a query from java class... on Created date column by using hibernate query language. The Problem is every
solve this problem
in table please tell me the solution for thid problem import java.io.*; import... = conn.createStatement(); String query = "insert into emp_sal values('zulfiqar', 15000)"; int i = statement.executeUpdate(query); if(i!=0
Hibernate code problem - Hibernate
Hibernate code problem  Hi, This is Birendra Pradhan.I want to create a DAO,who takes the connection from Hibernate.I want to use multiple query... & Regards Birendra  Hi friend, For solving the problem visit
problem in validation
problem in validation  sir/madam, i m using struts-1.3.10. i m getting a problem my properties file is not found.... while i hav configuired it in struts-config.xml file, likeADS_TO_REPLACE_1 thanks n regards himanshu
javascript problem
javascript problem  hi guys My problem is that I am using radio button for yes or no but i want to do that if I press yes button then enter... enter please help me this problem
query in JDBC
query in JDBC  What are the steps required to execute a query in JDBC
problem on strings
problem on strings  in string1 "123456 ABC DEF...",IN string2 "raveen". iwant to add string2 after 123456 in the first string based on index number.i need logic for this with out using StringBuffer concept. Thanks in advanace
Problem with loginbean.jsp
Problem with loginbean.jsp  http://www.roseindia.net/jsp/loginbean.shtml - I am getting an error in loginbean.jsp.There is some error regarding .What is hello in this? Also in this example how
compilation problem
compilation problem  struts 2.0 : i have included all 5 jars in lib folder,but its giving compilation problem that package open symphony doesnot... havenot set the build path.if this is the problem then tell me how to set
compilation problem
compilation problem  struts 2.0 : i have included all 5 jars in lib folder,but its giving compilation problem that package open symphony doesnot... havenot set the build path.if this is the problem then tell me how to set
Problem with cookies
Problem with cookies  Hello All, i need jsp code for RememberMe module of login. i am facing problem with cookies. so please if any one could guide me please help and provide mme the exact code.   Please visit
problem with package
problem with package  Dear sir, i have created one java file with package com.net; and i compiled the program.it showing the .class file in " net" folder.The problem is i want to use that .class file in some other
Oracle9i Problem
Oracle9i Problem  Hi I have a problem in Oracle9i .I have... the table what i created .But after closing the SQL+ ,the problem started.When i... .....;.it is saying no rows are selected.Why the problem arised in not getting the data that i
JScrollBar Problem...
JScrollBar Problem...  Hello Sir/mam, Can i know how to use JScrollBar to JFrame without adding any JPanel to it.. i want to add JScrollBar Directly to JFrame... Please Provide me Simple Example so i can understand
URL problem
URL problem  Hi. I have created a webpage for my project website. in that i have used frameset to split the page. Now if i click any link in the page its navigating to the another page. but the problem is here in the url its
problem with session.invalidate()
problem with session.invalidate()  i stuck by a line with "session.invalidate()", after user logout also by pressing the back button of the browser user is still able to navigate to his home page and able to view the session
Query conversion
Query conversion  can please convert the following mysql query to hibernate query select * from table1 where field1 not in (select field_1 from table3
Is AI a problem?
Is AI a problem?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: Is AI a problem? Try... "Is AI a problem?". Also tell me which is the good training courses
Skyline Problem
is the line tracing the largest y value from any rectangle in S The Problem: Write.... Your method should solve the problem three different ways; each solution
Problem in Array
Problem in Array  Hi, Can you help me with this problem? Run a program that check if the input string contains equal number of A's and B's. Hoping for your answer.Thank you.   Here is an example that check
problem
Problem
Problem
problem
problem
query optimization
query optimization  hai ! i need a code in java for database query optimization.plz help
query string
query string  Need some examples of query strings.send me as soon as possible. Regards, R.Santhosh
PROBLEM IDENTIFICATION
PROBLEM IDENTIFICATION  class MOrders { int nooforders; // Data members of the class public int getorder() { nooforders = 500; } public void displayorders() { System.out.println("The number of orders to be delivered
problem in coding
problem in coding  i have a following code which display the contents of the text file but not other program like java or any c program is there any handler to open the program files other than Filereader. FileReader fr = new
problem in html
problem in html  i want that my custmer can upload file or video on my website so plz help and send me the code which i can paste on my web site so people can upload their video and img and plz send the html code becaz my web
HttpSession problem :(
HttpSession problem :(  i want to ask that do i need to define httpsession in every servlet or jsp in my web application? if yes, then on which servlet? the very first one like my welcome page which comes after login page
Problem in enctype=
Problem in enctype=  im using a page which is in JSP. i have some text boxes and one upload button. i want to load the file itself when i click.... but the problem is the uploaded file is not stored in the prefered folder. i printed
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table name also is given by the user.My database is in mysql.Plsssss help me... Thanks
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table name also is given by the user.My database is in mysql.Plsssss help me... Thanks
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table name also is given by the user.My database is in mysql.Plsssss help me... Thanks
Problem with arraylist
Problem with arraylist  I am currently working on a java project and there is an if loop within the for loop.... for(int i = 1;i < iterationsNo.... It seems that problem
Query Question
Query Question  How would I write a query to display the name, department of the employee that earns the highest salary in the Employees table
PROBLEM IN EXECUTION
PROBLEM IN EXECUTION  class R { private int x; private int y; void getdata(int x1,int x2) { x=x1; y=y1; } void displaydata() { system.out.println(x+"\t"+y

Ads