Page 389 - 완) I MDP 프로젝트 작품 보고서(전체과 1학년)1.6
P. 389

인천전자마이스터고                                                                            전자회로설계과



                                conn.close();

                          }catch(SQLException se){
                             se.printStackTrace();
                          }//end finally try
                       }//end try
                       System.out.println("Goodbye!");

                    }//end main
            }//end FirstExample




            < DbSelect.java >

            import java.sql.*;


            public class DbSelect {


                    static String GetPw()

                    {
                            Connection conn = null;
                            Statement stmt = null;
                            ResultSet res = null;
                            String pw = null;

                            try{
                                    Class.forName("com.mysql.jdbc.Driver").newInstance();
                                    //System.out.println("Driver OK"); //driver 연결 확인
                                    String  url  =  "jdbc:mysql://192.168.0.34/rain";  //서버  주소  +
            database 이름

                                    String user = "test1"; //아이디
                                    String passwd = "test1"; //비번
                                    conn = DriverManager.getConnection(url,user,passwd);
                                    stmt = conn.createStatement();
                                    res = stmt.executeQuery("select * from login"); // login데이터 불

            러오기
                                    while(res.next()){
                                            pw = res.getString("pw");
                                    }



                            }




                                                         -  382  -
   384   385   386   387   388   389   390   391   392   393   394