service

service

package com.ilp.tsi.um.services;

import java.sql.*;

import com.ilp.tsi.um.beans.*;
import com.ilp.tsi.db.DB;

public class CreateService {

     public void  createRet(CreateBean x)
     {
         String id=x.getId();
         String name=x.getName();
         String password=x.getPassword();
         String contactno=x.getContact();
         String addr=x.getAddress();
         String email=x.getEmail();

         Connection conn=null;
         Statement stmt=null;
         ResultSet rs=null;
            try 
            {    
                DB dao=new DB();
                conn=dao.getConnection();    
                stmt=conn.createStatement();    

                rs = stmt.executeQuery("insert into RETAILER (RETAILER_ID, RETAILER_NAME, PASSWORD, CONTACT_NO, ADDRESS, EMAIL_ID) values ( '" +id+ "','" + name + "','"+password+"',' " + contactno + " ','" + addr + "','"+email+"')");       
                stmt.executeQuery("commit");

            }
            catch(Exception e)
            {        
                e.printStackTrace();    
            } 
            finally
            {
                try {
                    conn.close();
                    stmt.close();
                    } catch (SQLException e) {

                    e.printStackTrace();
                }


            }
//          return true;
     }

     public void CreateIm(CreateBean x)
     {
         String id=x.getId();
         String name=x.getName();
         String password=x.getPassword();
         String contactno=x.getContact();
         String addr=x.getAddress();


         Connection conn=null;
         Statement stmt=null;
         ResultSet rs=null;
            try 
            {    
                DB dao=new DB();
                conn=dao.getConnection();    
                stmt=conn.createStatement();    

                rs = stmt.executeQuery("insert into IM_DETAILS (IM_ID,IM_NAME,PASSWORD,CONTACT_NO,ADDRESS) values ( '" +id+ "','" + name + "','"+password+"',' " + contactno + " ',' " + addr + " ')");       
                stmt.executeQuery("commit");
            }
            catch(Exception e)
            {        
                e.printStackTrace();      
            } 
            finally
            {
                try {
                    conn.close();
                    stmt.close();
                    } catch (SQLException e) {

                    e.printStackTrace();
                }


            }
            //return rs; 
     }

     public Prodtag countRet(CreateBean cb)
     {
          Connection conn=null;
          Statement stmt=null;
          ResultSet rs=null,rs1=null;
            CreateService cs=new CreateService();
            Prodtag prodbean=new Prodtag();
          try
          {
            DB obj=new DB();
            conn=obj.getConnection();
            stmt=conn.createStatement();
            rs=stmt.executeQuery("SELECT COUNT(*) FROM RETAILER");

            int temp=0;
            //counting no of records in retailer table
            while(rs.next())
            {
            temp= rs.getInt("count(*)");
            }
            temp++;
            String id="";
            String temp1="";
            while(true)
            {


             temp1 = new Integer(temp).toString();
            id="RET".concat(temp1); //generating unique retailer ID

            rs1=stmt.executeQuery("select * from retailer where retailer_id='"+id+"'");
            if(rs1.next())
            {
                temp++;
                continue ;

            }
            else
            {
                break;
            }
            }
                cb.setId(id);
            String password=id;
                cb.setPassword(password);
            prodbean.setRetailerId(id);

            cs.createRet(cb);
          }
          catch(Exception e)
            {        
                e.printStackTrace();       
            } 
          finally
            {
                try {
                    conn.close();
                    stmt.close();
                    rs.close();
                    } catch (SQLException e) {

                    e.printStackTrace();
                }


            }
            return prodbean;
     }

     public ResultSet countIm(CreateBean cb)
     {
         CreateService cs=new CreateService(); 
         Connection conn=null;
          Statement stmt=null;
          ResultSet rs=null;
          try
          {
            DB obj=new DB();
            conn=obj.getConnection();
            stmt=conn.createStatement();
            rs=stmt.executeQuery("SELECT COUNT(*) FROM IM_DETAILS");
            int temp=0;
            //counting no of records in Inventory manager table
            while(rs.next())
            {
            temp= rs.getInt("count(*)");
            }
            temp++;
            String temp1=new Integer(temp).toString();
            String id="IM".concat(temp1); //generating unique Inventory manager ID
                cb.setId(id);
            String password=id;
                cb.setPassword(password);


            cs.CreateIm(cb);
          }
          catch(Exception e)
            {        
                e.printStackTrace();        
            } 
          finally
            {
                try {
                    conn.close();
                    stmt.close();
                    } catch (SQLException e) {

                    e.printStackTrace();
                }


            }
            return rs;
     }
}

-
-
-
-

package com.ilp.tsi.pm.services;
import java.sql.*;
import java.util.*;

import com.ilp.tsi.pm.beans.StockBean;
//import com.ilp.tsi.pm.dao.DaoPack;
//class for Stock
public class StockService{


//Adding stock
    public boolean AddStock(StockBean bean, Connection con) throws SQLException 

    {
        Statement stmt=null;
        ResultSet rs = null;
        boolean chk=false;

        String productId = bean.getProductId();

        String modelName = bean.getModelName();
        int quantity = bean.getQuantity();


        Random random=new Random();


        try
        {       String s=null;
                int count=0,c1=0,c2=0;  
                stmt = con.createStatement();
                rs=stmt.executeQuery("select * from advance where product_id='"+productId+"'");
                if(rs.next())
                {
                    //System.out.println("sdadasf "+rs.getString(1)+" "+rs.getString(2)+" "+rs.getInt(3));
                    s=rs.getString(1);
                    c1=rs.getInt(3);
                }
            for(int i=1;i<=quantity ;i++)
            {
                int  rand_no= random.nextInt();
                String temp=productId.concat(modelName);
                String productCode=temp+rand_no;
                c2++;
                if(c2>c1)
                {
                rs =stmt.executeQuery("insert into stock (product_id,product_code,prod_model_name,status)values ('"+productId+"','"+productCode+"','"+modelName+"', 'available')");
                stmt.executeQuery("commit");
                }
                else
                {
                    System.out.println("gffsdghsdfhsdfhjdfhjdfhdg ");
                    stmt.executeUpdate("insert into stock (product_id,product_code,prod_model_name,status,order_id)values ('"+productId+"','"+productCode+"','"+modelName+"', 'allocated','"+s+"')");
                    count++;
                }
                rs=stmt.executeQuery("select count(*) from stock where product_id='"+productId+"'");

                if (rs.next())
                { bean.setQuantity(Integer.parseInt(rs.getString(1)));


                }

            }
            count=c1-count;
            System.out.println("gergsghshjs "+count);
            stmt.executeUpdate("update advance set quant_reqd='"+count+"' where product_id='"+productId+"' and order_id='"+s+"'");
            stmt.executeUpdate("update product set quantity="+bean.getQuantity()+" where product_id='"+productId+"'");                  
            chk=true;  

        }
                catch(SQLException e)
                    {


                    }
                finally{
                    rs.close();
                    stmt.close();
                    con.close();
                }
        return chk;
        }

//Getting product model name

public StockBean productModelName(StockBean sb,Connection con) throws SQLException
    {
        Statement st=null;
        ResultSet rs = null;
        try
        {


            String productId =sb.getProductId();
            st= con.createStatement();                  
            rs = st.executeQuery("select * from product where product_id='" + productId + "'");
            while(rs.next())
        {
                sb.setProductId(rs.getString(1));
                sb.setModelName(rs.getString(2));
//              System.out.println(sb.getModelName());

            }
//          System.out.println("Search completed.");


        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        finally
        {
            rs.close();
            st.close();
            con.close();
        }
        return sb;
    }

    //Deleting stock

    public boolean deleteStock(StockBean bean, Connection con) throws SQLException 

    {
        Statement stmt=null;
        ResultSet rs = null;
        int count=0;
        boolean chk=false;
        String productId = bean.getProductId();
        String modelName = bean.getModelName();

        String productCode = bean.getProductCode();

//      System.out.println("this is from delete service---");
//      System.out.println(productId);
//      System.out.println(modelName);
//      System.out.println(productCode);


        try
        {           
                stmt = con.createStatement();
//          System.out.println("service page3");
//          System.out.println(productCode);
//              System.out.println("delete from stock where productCode='"+productCode+"'");
    rs =    stmt.executeQuery("delete from stock where product_code='"+productCode+"'");
    stmt.executeQuery("commit");
    rs=stmt.executeQuery("select count(*) from stock where product_id='"+productId+"'");

    if (rs.next())
    { bean.setQuantity(Integer.parseInt(rs.getString(1)));


    }
    rs=stmt.executeQuery("select *from stock where product_id='"+productId+"'");


    rs=stmt.executeQuery("update product set quantity="+bean.getQuantity()+" where product_id='"+productId+"'");
//  System.out.println("product table Successfully updated");
    chk=true;
    }

    catch(SQLException e)
        {
//          System.out.println(e);
        }
    finally{
        rs.close();
        stmt.close();
        con.close();
        }
        return chk;
    }



        }   



-
-
-
-

package com.ilp.tsi.om.services;
import java.sql.*;

import com.ilp.tsi.om.beans.UpdateCusBean;

public class UpdateService 
{
    /*
     * updates customer info in the Db
     */
    public boolean updating(UpdateCusBean updatecusbean, Connection connection)throws SQLException 
    {
        Statement statement = null;
        try 
        {
            String customerid = updatecusbean.getCustomerId();
            String customername =updatecusbean.getCustomerName();
            String customeradd= updatecusbean.getCustomerAddress();
            String contactno=updatecusbean.getContactNumber();
            statement=connection.createStatement();
            statement.executeUpdate("update customer set cust_name='"+customername+"' ,address='"+customeradd+"',contact_no='"+contactno+"' where cust_id='"+customerid+"'");
            return true;            
        } 
        catch (SQLException sqle) 
        {
            connection.close();
            return false;
        } 
        catch (Exception e) 
        {
            connection.close();
            return false;
        }
        finally
        {
            connection.close();
            statement.close();
        }
    }       
}

-
-
-
-
-

package com.ilp.tsi.db;
import com.ilp.tsi.utils.*;
import java.sql.*;
public class DB {
    Connection conn=null;
    public Connection getConnection()
    {
        try
        {
            Class.forName(Constant.DRIVER);
        }
        catch(Exception E)
        {
            E.printStackTrace();
        }
        try{
            conn=DriverManager.getConnection(Constant.URL,Constant.username,Constant.pwd);
        }
        catch(Exception E)
        {
            E.printStackTrace();
        }

        return conn;

    }

}

-
-
-
-

package com.ilp.tsi.utils;

public class Constant {
public static final String DRIVER="oracle.jdbc.driver.OracleDriver";
public static final String URL="jdbc:oracle:thin:@172.24.137.30:1521:ORA10G";


}
View Answers









Related Tutorials/Questions & Answers:
servlet Service
servlet Service  Defined servlet Service
web service
web service  i want to make an web service example so please help me out thanks  
Advertisements
web service
would be grateful :):) So i want to creat a web service that display the bus... coordinate will be send to my web service in a array list but i cant translate this into a code; my problem is in the web service side : in wich class i will do
Flex as a Service
Flex as a Service  Hi....... just tell me about How do I run Flex as a service? please give me an example if possible Thanks  Ans: Flex is not a server. It is the pert of your web application. you can use
xcode web service example
xcode web service example  xcode web service example
Mocking a service that calls another service
Mocking a service that calls another service  I have a method, say m1 in class, say C1. Method m1 calls a method, say m2 from another service class, say C2. So I mock m2 in junit test-cases for m1. However, m2 itself calls
service
Web Service
"; ServiceFactory factory = ServiceFactory.newInstance(); Service service
Web Service
"; ServiceFactory factory = ServiceFactory.newInstance(); Service service
ModuleNotFoundError: No module named 'as-a-service'
ModuleNotFoundError: No module named 'as-a-service'  Hi, My Python... 'as-a-service' How to remove the ModuleNotFoundError: No module named 'as-a-service' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'service'
ModuleNotFoundError: No module named 'service'  Hi, My Python... 'service' How to remove the ModuleNotFoundError: No module named 'service... to install padas library. You can install service python with following command
ModuleNotFoundError: No module named 'as-a-service'
ModuleNotFoundError: No module named 'as-a-service'  Hi, My Python... 'as-a-service' How to remove the ModuleNotFoundError: No module named 'as-a-service' error? Thanks   Hi, In your python
unable to open the service tomcat5
unable to open the service tomcat5  While trying to run tomcat server getting "unable to open the service tomcat5" error after installed tomcat
restart elasticsearch service centos
restart elasticsearch service centos  Hi I have elasticsearch server on Centos. How to restart elasticsearch service centos? Thanks   Hi, In centos elasticserch is installed as service. It can be restarted
VoIP Service
VoIP Service VoIP Service Provider Solutions Emergent Network Solutions mission is to provide real, deliverable VoIP service provider solutions. Our suite of VoIP service provider solutions software combines the best of proven
Web service protocol stack
Web service protocol stack  hii, What is the Web service protocol stack?   hello,ADS_TO_REPLACE_1 The Web service protocol stack is an evolving set of protocols used to define, discover, and implement Web services
How to Convert SOAP Web service to REST Web service In Java ?
How to Convert SOAP Web service to REST Web service In Java ?  I want to Convert SOAP Web service(WSDL) to REST web service in JSON Format with GET... service. What I know is that JAX-RS api is used to generate REST Web service
Web Service Tutorial - WebSevices
Web Service Tutorial  hi, i am asking you again for my previous question of web service. you told me about a link but there is no link in your... the attachment of a step by step procedure of creating web service. Thanks and Regards
MongoDB uninstall windows service
the MongoDB on my Winodws Computer as service. Now I want to uninstall the mongodb from windows service. Can any one tell me How to uninstall the MongoDB from windows server? Thanks   Hi, You can remove the MongoBD service using
What is the default cache service of hibernate?
What is the default cache service of hibernate?  Hi, What is the default cache service of hibernate? Thanks
Creating a service - JSP-Servlet
the results.The DAO Is written using Hibernate Then I should create a service which...) to get the data back from the database.(Service is a seperate class not like webservice ect) Can anyone tell me how to create a service.   
Web Service Tutorial - WebSevices
Web Service Tutorial  hi, i am new to web service and not much have idea about web services. right now i am using myeclipse blue 7.1 as my java IDE... the steps of creating a simple web service. Thanks and Regards Nishi
web service & database
web service & database  Hi, I need help with importing data from web service to ms sql/my sql. I developed a web service using Axis2 (v1.6.2) and Tomcat (v7.0.27) running on Eclipse Indigo. I can connect to the web services
Web Service - WebSevices
Web Service  Hi All I have web service in .net , and i have to call it from java spring. How can i do it? Thanks
web service client
web service client  i have implement web service client in netbeans and it work will using wsdl but know i want to Develop a webserivce (or a Java RMI server/client) for one of the e-services but i do not know the wsdl link how
web service frameworks
Web service Frameworks         Web service Frameworks: There are many frameworks for web services. Here is the list of some frameworks
web service protocols
Web service Protocols         Web service protocols: Here is the list of some protocols used for Web Services:ADS_TO_REPLACE_1
Version of com.disdar>extraction-service dependency
List of Version of com.disdar>extraction-service dependency
Version of com.intersult>abraxas-service dependency
List of Version of com.intersult>abraxas-service dependency
Version of com.ricardoespsanto>onesky-service dependency
List of Version of com.ricardoespsanto>onesky-service dependency
Version of com.sdl>odata_service dependency
List of Version of com.sdl>odata_service dependency
Version of com.shipdream>service-core dependency
List of Version of com.shipdream>service-core dependency
Version of com.tsc9526>monalisa-service dependency
List of Version of com.tsc9526>monalisa-service dependency
Fax service in Java application.
Fax service in Java application.  Hello, I want to develop a Java application to send fax to any destination fax numbers. Anyone who knows about this, please tell how I can do this. Is there any free libraries
web service - JSP-Servlet
web service  How to call a web service from JSP post method?  Method in JSPHi! In this JSP Example you'll see, how to call web service from JSP methodName the file as usingMethod.jsp JSP Code- - - - -<%@ page
ModuleNotFoundError: No module named 'async-service'
ModuleNotFoundError: No module named 'async-service'  Hi, My... 'async-service' How to remove the ModuleNotFoundError: No module named 'async-service' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'bert-service'
ModuleNotFoundError: No module named 'bert-service'  Hi, My Python... 'bert-service' How to remove the ModuleNotFoundError: No module named 'bert-service' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'completion-service'
ModuleNotFoundError: No module named 'completion-service'  Hi, My... named 'completion-service' How to remove the ModuleNotFoundError: No module named 'completion-service' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'completion-service'
ModuleNotFoundError: No module named 'completion-service'  Hi, My... named 'completion-service' How to remove the ModuleNotFoundError: No module named 'completion-service' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'elasticsearch-service'
ModuleNotFoundError: No module named 'elasticsearch-service'  Hi...: No module named 'elasticsearch-service' How to remove the ModuleNotFoundError: No module named 'elasticsearch-service' error? Thanks   Hi
ModuleNotFoundError: No module named 'embedding-as-service'
ModuleNotFoundError: No module named 'embedding-as-service'  Hi...: No module named 'embedding-as-service' How to remove the ModuleNotFoundError: No module named 'embedding-as-service' error? Thanks   Hi
ModuleNotFoundError: No module named 'fairness-service'
ModuleNotFoundError: No module named 'fairness-service'  Hi, My... named 'fairness-service' How to remove the ModuleNotFoundError: No module named 'fairness-service' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'iscc-service'
ModuleNotFoundError: No module named 'iscc-service'  Hi, My Python... 'iscc-service' How to remove the ModuleNotFoundError: No module named 'iscc-service' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'livestatus-service'
ModuleNotFoundError: No module named 'livestatus-service'  Hi, My... named 'livestatus-service' How to remove the ModuleNotFoundError: No module named 'livestatus-service' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'modelling-service'
ModuleNotFoundError: No module named 'modelling-service'  Hi, My... named 'modelling-service' How to remove the ModuleNotFoundError: No module named 'modelling-service' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'modelling-service'
ModuleNotFoundError: No module named 'modelling-service'  Hi, My... named 'modelling-service' How to remove the ModuleNotFoundError: No module named 'modelling-service' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'mqtt-service'
ModuleNotFoundError: No module named 'mqtt-service'  Hi, My Python... 'mqtt-service' How to remove the ModuleNotFoundError: No module named 'mqtt-service' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ocr-service'
ModuleNotFoundError: No module named 'ocr-service'  Hi, My Python... 'ocr-service' How to remove the ModuleNotFoundError: No module named 'ocr-service' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'ocr-service'
ModuleNotFoundError: No module named 'ocr-service'  Hi, My Python... 'ocr-service' How to remove the ModuleNotFoundError: No module named 'ocr-service' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'oriole-service'
ModuleNotFoundError: No module named 'oriole-service'  Hi, My... named 'oriole-service' How to remove the ModuleNotFoundError: No module named 'oriole-service' error? Thanks   Hi, In your python

Ads