Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

result problem

Ads

 
 

Share on Google+Share on Google+

kishan gupta
result problem
1 Answer(s)      6 years and 8 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){ } } }

Ads
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


Ads









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
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 - 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
StringTokenizer not returning proper result
. I tried to change datatype to String still the problem persists. And when I
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
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
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
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 problem
php problem  Hello!! I have a problem ,i want to display the data....'" LIMIT 1'; $result = mysql_query( $sql); if(! $result) { die('Could not get data: ' . mysql_error()); } while($row = mysqlfetchassoc($result, MYSQL_ASSOC
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
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
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
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="
problem i coding
problem i coding  i have a problem in coding a combobox containing a number of *.java program on click one of them that program should compile and run and display the result in other window
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
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
Version of com.allenru>jackson-morphed-result dependency
List of Version of com.allenru>jackson-morphed-result dependency
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 : <
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
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