Supplier query in POS Management System

Source: Internet
Author: User

<% @ Page Language = "Java" Import = "Java. util. *" pageencoding = "UTF-8" %>

<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en">
<HTML>
<Head>

<Title> my JSP 'loginservlet. jsp 'starting page </title>

</Head>

<Body>
<Form action = "<% = request. getcontextpath () %>/mfredit1.do" method = "Post">
<Table border = "1">
<Tr>
<TD> vendor code </TD>
<TD> <input type = "text" name = "CNO">
<Input type = "hidden" name = "method" value = "find"/>
</TD>
</Tr>
<Tr>
<TD>
<Input type = "Submit" value = "query"/>
</TD>
</Tr>
</Table>
</Form>
</Body>
</Html>

Package servlet;

Import java. Io. ioexception;
Import java. SQL. connection;
Import java. SQL. drivermanager;
Import java. SQL. preparedstatement;
Import java. SQL. resultset;
Import java. SQL. sqlexception;
Import java. util. arraylist;
Import java. util. List;

Import javax. servlet. requestdispatcher;
Import javax. servlet. servletexception;
Import javax. servlet. http. httpservlet;
Import javax. servlet. http. httpservletrequest;
Import javax. servlet. http. httpservletresponse;

Import entity. cusinfo;

@ Suppresswarnings ("serial ")
Public class editservlet1 extends httpservlet {
Private final string url = "JDBC: oracle: thin: @ 127.0.0.1: 1521: orcl ";
Private final string user = "gsuser ";
Private final string Pwd = "160127 ";
 
@ Override
Protected void doget (httpservletrequest req, httpservletresponse resp)
Throws servletexception, ioexception {

Dopost (req, resp );
}

@ Override
Protected void dopost (httpservletrequest req, httpservletresponse resp)
Throws servletexception, ioexception {
Req. setcharacterencoding ("UTF-8 ");
String CNO = Req. getparameter ("CNO ");
Int I = deletemfredit (CNO );
If (I> 0 ){
// Deletion successful
Resp. sendredirect (req. getcontextpath () + "/success. jsp ");
} Else {
Resp. sendredirect ("http://www.sohu.com ");
}

}
Private int deletemfredit (string CNO ){
String Delete = "delete from mfredit A where a. CNO =? ";
Int I = 0;
// Load the driver
Try {
Class. forname ("oracle. JDBC. Driver. oracledriver ");
} Catch (classnotfoundexception e ){
E. printstacktrace ();
}
Connection conn = NULL;
Preparedstatement pstmt = NULL;
Try {
Conn = drivermanager. getconnection (URL, user, PWD );
Pstmt = conn. preparestatement (delete );
// Set parameters
Pstmt. setstring (1, CNO );
// Pstmt. setstring (2, cname); // Execute
I = pstmt.exe cuteupdate ();
} Catch (sqlexception e ){
E. printstacktrace ();
} Finally {
Try {
If (pstmt! = NULL ){
Pstmt. Close ();
}
If (Conn! = NULL ){
Conn. Close ();
}
} Catch (sqlexception e ){
E. printstacktrace ();
}
}
Return I;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.