How to write the set method in java to enter the values in the database as a user interface platform -


i hav written code but, couldnot write code of set method.please tell me if making user interface how should write set method.my code package com.glomindz.mercuri.dao;

import java.sql.connection; import java.sql.preparedstatement; import java.sql.resultset; import java.sql.sqlexception; import java.util.arraylist; import java.util.list;  import com.glomindz.mercuri.pojo.package; import com.glomindz.mercuri.util.mysingleton;    public class packageservicesdao {  private connection connection;  public packageservicesdao() {     // connection = new mysingleton().getconnection();     connection = mysingleton.getinstance().getconnection();  }  public list<package> get_all_data() {     list<package> packagelist = new arraylist<package>();      string query = "select * spl_package_master";     try {          preparedstatement stmt = connection.preparestatement(query);          boolean execute = stmt.execute();         system.out.println(execute);         resultset resultset = stmt.getresultset();         system.out.println(resultset.getmetadata());         while (resultset.next()) {             package pack = new package();             pack.setid(resultset.getint("id"));             pack.setvolume(resultset.getstring("volume"));             pack.setunit_type(resultset.getstring("unit_type"));             pack.setquantity_in_box(resultset.getint("quantity_in_box"));             pack.settype(resultset.getstring("type"));             packagelist.add(pack);         }     } catch (sqlexception e) {         // todo auto-generated catch block         e.printstacktrace();     }        return packagelist;     }       public boolean set_all_data() {         package packages = new package();         boolean result = false;             try {              preparedstatement stmt = connection.preparestatement("insert spl_package_master(volume,unit_type,quantity_in_box,type)values(?,?,?,?)");              stmt.setstring(1, packages.getvolume());              stmt.setstring(2, packages.getunit_type());              stmt.setint(3, packages.getquantity_in_box());              stmt.setstring(4, packages.gettype());                result = stmt.execute();           }           catch (sqlexception e) {             // todo auto-generated catch block             e.printstacktrace();         }          return result;         }   public static void main(string[] args) {     packageservicesdao pacdao = new packageservicesdao();     list<package> data = pacdao.get_all_data();     boolean data1 = pacdao.set_all_data();     system.out.println(data);     system.out.println(data1);     system.exit(0); } 

}


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -