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



Home Answers Viewqa JDBC result problem
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


kishan gupta
result problem
1 Answer(s)      3 years and 11 months ago
Posted in : JDBC


sir,i have written program given below but that program is not giving proper output.pls help me

import java.io.*;

import javax.servlet.*; import javax.servlet.http.*; import java.sql.*;

class filedata extends HttpServlet { public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException { String name1=req.getParameter("name"); try {

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:test","",""); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("select * from studentbase where name=name1");

res.setContentType("text/html"); PrintWriter pw=res.getWriter();

while(rs.next()) { pw.println(rs.getString("name")); } con.close(); } catch(ClassNotFoundException e){ } catch(SQLException e){ } } }


Advertisement
View Answers

November 29, 2010 at 11:56 AM


Hi Friend,

Try the following code:

1)form.jsp:

<html>
<form name="form" method="post" action="../Data">
Enter Message: <input type="text" name="name">
<input type="submit" value="submit">
</form>
</html>

2)Data.java:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;

public class Data extends HttpServlet { 
    public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException {
        String name1=req.getParameter("name");
        System.out.println(name1);
        try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:student","","");
    Statement stmt=con.createStatement();
    ResultSet rs=stmt.executeQuery("select * from data where name='"+name1+"'");
    res.setContentType("text/html"); 
    PrintWriter pw=res.getWriter();
    while(rs.next()) {
        pw.println(rs.getString("name"));
        } 
        con.close();
        } 
        catch(ClassNotFoundException e){ }
        catch(SQLException e){
        }
        }
        }

Thanks



Related Tutorials/Questions & Answers:
result problem
result problem  sir,i have written program given below but that program is not giving proper output.pls help me import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; class filedata extends
JSP - Problem of displaying result at webpage
JSP - Problem of displaying result at webpage  Can anyone please help to solve my problem below. My webpage has problem in displaying result position. The result should be display below my title. How do i solve it? Thank you so
Advertisements
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();it.hasNext();){ Object[] row = (Object[]) it.next
display result
display result  i want a code that takes input from user through dropdown box and display the result into table.all the values regarding the user input must be displayed. i am using mysql database   hi i want study
result after compilation
result after compilation  public class MainCls { public static void main(String argv) { System.out.println("My text
Result=Set - Java Beginners
Result=Set  Hi Friend, Can u tell how to get the count of records. in a select operation like sqlstmt="SELECT * FROM search_log_tab WHERE... result set, first move the pointer from first record to last record and get
Sort Result set
Sort Result set   I build a connect for my page with the database and then read all rows and show it in a table, I want to change the view of my data to be sorted uppon a specific column when click on the column name, so what
result analysis issue
result analysis issue  i have given 100 users in my thread group for http sampler.some threads r getting response and some threads r getting error response.the error response shown in view results tree listener is as shown below
StringTokenizer not returning proper result
. I tried to change datatype to String still the problem persists. And when I
write the result into excelsheet
write the result into excelsheet  package reader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import... the result in to the same excel file....... please help me. if username is superadmin
hide and show result in jsp
hide and show result in jsp  what codes do i have to change to make my result display if only i enter the correct value? suppose if i click search,then the result will be display at the bottom.. if not.. only the header
java.sql.SQLExceptioan: Before start of result set - JDBC
java.sql.SQLExceptioan: Before start of result set   java.sql.SQLException: Before start of result set?what do i do?   Hi Friend, It seems that there is a problem with the resultSet.next() method: It is used before
Result Set one to many mapping
Result Set one to many mapping  Suppose there are 5 tables... Suppose result contains single entry of One record for A, Two records for B... solution to this problem
getting result in table dynamically - Struts
getting result in table dynamically  How do i get result in tabular format dynamically using our own tags
Result interface in Struts 2.2.1
Result interface in Struts 2.2.1 Struts Result interface is a public interface of package com.opensymphony.xwork2. It extends Serializable interface. All the known classes such as PlainTextResult, ServletRedirectResult, 
Php Sql Result
Php Sql Result This example illustrates how to display result on the browser and how to use the result in the php application. In this example we create a select query by using mysql_query method and stored it in the result variable
Stream Result example
Stream Result example Stream Result is very important for allowing users to downloading contents. It is a custom result type for sending raw data via... Result is given below page.jsp <%@ taglib prefix="s" uri="
how to chech result set is null or not - Java Beginners
how to chech result set is null or not  Hi, really very thanks for fast reply.I want to know how to check whether the result set is null... in solving the problem : import java.sql.*; public class CheckResultSet
Dispatcher Result Example
Dispatcher Result Example The Dispatcher Result forwarded the action... dispatcher in result you need to do the following mapping. <action name="dispatcherAction" class="....."> <result name="
Hibernate Criteria Setfirst Result
Hibernate Criteria SetFirstResult Result The setFirstResult of hibernate criteria API is used for setting no of records to be fetched from the table criteria.setFirstResult(1); An example of set first is given below
A Java Program That Prints Out Result Via Printer
A Java Program That Prints Out Result Via Printer  A Java Program That Prints Out Result Through Printer Depending upon paper size , and print the calculated result on printer and save result as text file
how can i display a editable result of form?
how can i display a editable result of form?  how can i display a editable result of form? i know how to display form result but the result... to display form result in same page i have alredy created a hidden div which
PHP SQL Result
PHP SQL Result       This example illustrates how to display result on the browser and how to use the result in the php application. To understand how to display the result
XSL Result and its example
XSL Result and its example XSLT stands for XSL Transformations. It is the most... or add the attribute from the output file. An Example of XSLT result is given...; <body> <h2>XSLT Result Example</h2> <h4>Name : <
Dropdown code to retrieve result from oracle database
Dropdown code to retrieve result from oracle database  Hi Friends, I... retrieve the result from Oracle database.We have procedures created already.Just need to fetch the result when the dropdown is chosen.Can anyone please help me
STRUTS 2 Could not find action or result
on my log: WARNING: Could not find action or result There is no Action...="pkg.MenuListAction" method="execute"> <result name="success" >...;/html> plzz help me out...i might have problem in my struts.xml...its
select result from three tables using sql.
select result from three tables using sql.  I want to get a result from three tables. i dont how to write the sql query. Please help me. "I want to display Name,Username and Product_Name where Id=007" table "register" Name
Hibernate Narrowing Criteria Result Set
Hibernate Narrowing Criteria Result Set In this tutorial you will learn how to narrow the Criteria result set. In Hibernate result set can be narrowed... how can you narrow the result set. For creating this example at first I have
Jsp not display desired result - JSP-Servlet
friend, For solving the problem visit to : http://www.roseindia.net/jsp
hibernate criteria Unique Result Example
hibernate criteria Unique Result Example In this Example, We will discuss... method. In This example search the result according to Criteria Restriction  and setMaxResults condition. The unique result method is Convenience method
how to sort the result of this 2 class program in java.....????
how to sort the result of this 2 class program in java.....????  package setget1_method; import java.util.Scanner; public class Main { { { Scanner input = new Scanner(System.in); LBook[] book = new LBook[5]; String
Advertisements
 

 

 

DMCA.com