Page 223 - 3-1
P. 223

package MDP;


              import java.sql.Connection;
              import java.sql.PreparedStatement;
              import java.sql.ResultSet;
              import java.sql.SQLException;
              import java.util.ArrayList;


              import MDP.*;


              public class ToolDAO{
                      StringBuffer sb = new StringBuffer();
                      ResultSet rs = null;
                      PreparedStatement pstmt = null;
                      Connection conn = null;


                      public ToolDAO(){
                              conn = Makeconnection.getInstance().getConnection();


                              sb.setLength(0);
                              sb.append("use Tool ");


                              try{
                                      pstmt = conn.prepareStatement(sb.toString());
                                      pstmt.executeQuery();
                              }catch(SQLException e){
                                      e.printStackTrace();
                              }
                      }


                      public ArrayList<ToolVo> getAllData(){
                              ArrayList<ToolVo> list = new ArrayList<ToolVo>();


                              sb.setLength(0);
                              sb.append("select * from Tool ");


                              try{
                                      pstmt = conn.prepareStatement(sb.toString());
                                      rs = pstmt.executeQuery();





                                                         - 223 -
   218   219   220   221   222   223   224   225   226   227   228