디시인사이드 갤러리

갤러리 이슈박스, 최근방문 갤러리

갤러리 본문 영역

소스고치는것좀 도와줘요ㅠㅠ

ㅇㅕ대생(124.55) 2011.09.23 00:01:48
조회 88 추천 0 댓글 2

4학년인데 프밍실력이 없어서ㅜㅜ
저희가 연결시키고싶은건
jdbc:oracle:thin:@:1521:XE
아이디 scott
비번 tiger
인데 어디를 고쳐야할지 모르겠어요 도와주세요..

 

 

public String ConnectToDB() {
  String retval = "";
  String url, pass;
  try {
   try {
    Class.forName("org.postgresql.Driver");// get psql driver class
   } catch (ClassNotFoundException y) {
    lbStatus.setText(String.format("Class loading error: %s",
      y. toString()));
   }

   if (!jEnabled.isSelected())// ssh tunneling disabled
   {
    url = "jdbc:postgresql://" + lbServer.getText();
   
    pass = String.copyValueOf(lbPass.getPassword());
   } else// use ssh tunneling
   {
    if (retval != "")
     retval += "\\n";
    // attempt to portforward 5432 from ssh connection to the
    // localhost
    retval += PortForward();
    url = "jdbc:postgresql://localhost";
   
    pass = String.copyValueOf(lbPass.getPassword());
   }

   // connect to the psql database
   con = DriverManager.getConnection(url, lbUser.getText(), pass);

   if (retval != "")
    retval += "\\n";
   retval += "Connection Successful!";
   Connected = true; // set the connection state to true if all goes
        // well
   return retval;

  } catch (java.lang.Exception ex) {
   if (retval != "")
    retval += "\\n";
   retval += String.format("Connection Failed!: %s ", ex. toString());
   return retval;
  }
 }

 /**
  * Executes a sql query on the connected psql database
  *
  * @param Query
  *            a String representing the sql query to execute on the
  *            database.
  * @return A ResultSet object containing the results of executing the Query
  *         String on the psql database. It will return null if the
  *         dbConnection is not connected to a psql database or there is an
  *         error.
  */
 public ResultSet ExecuteQuery(String Query) {
  if (!Connected)
   return null;
  else {
   try {
    Statement stmt = con.createStatement();
    return stmt.executeQuery(Query);
   } catch (SQLException ex) {
    JOptionPane.showMessageDialog(null, ex.getMessage());
    return null;
   }
  }
 }

 /**
  * Attempts to connect to the ssh tunnel and forward the port 5432 (psql
  * server) from the secure connection to the localhost.
  *
  * @return error/status String
  */
 private String PortForward() {
  try {
   JSch jsch = new JSch();

   session = jsch.getSession(sshUser.getText(), sshHost.getText(), 22);

   int lport = 5432;
   String rhost = lbServer.getText();
   int rport = lport;

   // username and password will be given via UserInfo interface.
   UserInfo ui = new MyUserInfo();
   session.setUserInfo(ui);

   session.connect();

   session.setPortForwardingL(lport, rhost, rport);

   return "Port Forwarding Successful";
  } catch (Exception e) {
   return (String.format("SSH Tunneling error: %s", e. toString()));
  }
 }

 /**
  * An implementation of the UserInfo interface specified in the jsch library
  * used to implement ssh tunneling. The user info is taken from the form
  * itself so this is more or less just a stub of an implementation of the
  * interface.
  */
 public class MyUserInfo implements UserInfo {
  /**
   * Gets the password for the ssh tunnel connection
   *
   * @return A String representing the password for the ssh tunnel. It is
   *         taken from the dbConnection form sshPass password box.
   */
  public String getPassword() {
   return String.copyValueOf(sshPass.getPassword());
  }

  /**
   * supposed to get the passPhrase for the ssh tunnel
   *
   * @return returns null as this method is not really used in my program,
   *         but is necessary to complete implement the UserInfo interface
   *         from the jsch library
   */
  public String getPassphrase() {
   return null;
  }

  /**
   * prompts for password entry for ssh tunnel
   *
   * @param message
   *            password prompt String
   * @return true
   */
  public boolean promptPassword(String message) {
   return true;
  }

  /**
   * prompt with a yes/no response
   *
   * @param message
   *            String message to be displayed in the yes/no prompt
   * @return true
   */
  public boolean promptYesNo(String message) {
   return true;
  }

  /**
   * prompts for passphrase for ssh tunnel
   *
   * @param message
   *            message to be displayed in prompt
   * @return true
   */
  public boolean promptPassphrase(String message) {
   return true;
  }

  /**
   * supposed to diplay a message
   *
   * @param message
   *            message to display
   */
  public void showMessage(String message) {
   return;
  }
 }

 

추천 비추천

0

고정닉 0

0

댓글 영역

전체 댓글 0
본문 보기

하단 갤러리 리스트 영역

왼쪽 컨텐츠 영역

갤러리 리스트 영역

갤러리 리스트
번호 제목 글쓴이 작성일 조회 추천
설문 끝까지 다 본 걸 후회하게 만든 용두사미 드라마는? 운영자 25/07/07 - -
275192 근데 얼호 너 남자 아니냐?? [3] 쿄스케갤로그로 이동합니다. 11.09.23 69 0
275191 정통부가 있었으면 내가 거기 의견을 제출했을텐데... [6] 거칠게갤로그로 이동합니다. 11.09.23 78 0
275190 형들 저 급해요 ㅠㅠ 저 좀 도와주세요 ㅠㅠ 멸자(130.126) 11.09.23 27 0
275189 여자들이 성욕이 더 강한건 알고 그러는거냐??? [3] 거칠게갤로그로 이동합니다. 11.09.23 145 0
275188 존나 궁금한게있는데 왜 조회수만 60이넘음? [5] 힙꼬맹갤로그로 이동합니다. 11.09.23 63 0
275186 입갤/ 왠 여자냐 [4] 三didas갤로그로 이동합니다. 11.09.23 74 0
275185 즐거운 점심시간이다. 나 입겔이염~~ [7] 거칠게갤로그로 이동합니다. 11.09.23 61 0
275184 아 씨 ㅠㅠ 그 대학원생이랑 내일 점심 먹기로 했는데 [8] 멸자(130.126) 11.09.23 94 0
275183 내가 바이크 살라고 모아둔 돈이 있거든 [19] 얼빠진호랑이갤로그로 이동합니다. 11.09.23 205 0
275182 jsp가 대세임? [5] 뇌지랄갤로그로 이동합니다. 11.09.23 122 0
275181 어휴 미친 게이세끼들 [2] Adelposs갤로그로 이동합니다. 11.09.23 58 0
275180 힙꼬맹 봅니다 [12] 지금,여기갤로그로 이동합니다. 11.09.23 67 0
275179 C# 배열문제 제발 답좀 형들. [2] ㅇㅇ2(203.247) 11.09.23 82 0
275176 힙꼬맹 몇살임? [8] 멸자(130.126) 11.09.23 68 0
275173 일베는 지금,여기갤로그로 이동합니다. 11.09.23 37 0
275172 스타 북미 서버 다레기가 멸자(130.126) 11.09.23 28 0
275169 쿄스케형 오늘 점심으로뭐드셨나요? [4] Light search갤로그로 이동합니다. 11.09.23 57 0
275167 외장하드에 와우를 깔아놨는데 [4] 얼빠진호랑이갤로그로 이동합니다. 11.09.23 128 0
275166 아 배필 3 가 나온다니 ㅠㅠ [1] 멸자(130.126) 11.09.23 41 0
275165 노량진가면 먹을거 천국이라는데 [1] 힙꼬맹갤로그로 이동합니다. 11.09.23 43 0
275164 잉 ㅋㅋㅋㅋ 인천 정전이라니 [1] 힙꼬맹갤로그로 이동합니다. 11.09.23 43 0
275163 모아둔 돈이 있는데 컴터나 살까 [26] 얼빠진호랑이갤로그로 이동합니다. 11.09.23 164 0
275162 유동닉이라도 ㅁㄴㅇㄹ에서 멸자로 닉 바꿔야지 [1] 멸자(130.126) 11.09.23 32 0
275161 대구 맛집 #1 [4] monoless갤로그로 이동합니다. 11.09.23 54 0
275160 근데 진짜 클라우드 컴퓨팅이 뭐임? [3] ㅁㄴㅇㄹ(130.126) 11.09.23 73 0
275159 너희에겐 너희의 일이 있음 [2] 분당살람갤로그로 이동합니다. 11.09.23 64 0
275156 너희는 도를 믿냐고 햇냐? 나는 [7] Adelposs갤로그로 이동합니다. 11.09.23 72 0
275155 나 좆 대딩 1학년인데 [1] ㅁㄴㅇㄹ(130.126) 11.09.23 65 0
275154 포인터 무개념 [9] 유리한갤로그로 이동합니다. 11.09.23 184 0
275153 난 인순이가 싫다. 이메지네이션(116.124) 11.09.23 60 0
275151 gcd(0,0) 은 뭐임? [2] ㅁㄴㅇㄹ(130.126) 11.09.23 58 0
275149 자신이 서버쪽 개발에 자신있다 거수 [4] 씨발라드세요갤로그로 이동합니다. 11.09.23 90 0
275147 형들 나 물어볼게 좀 있어 [23] 얼빠진호랑이갤로그로 이동합니다. 11.09.23 218 0
275146 아 요새 고민이 넘 많아.. 횽들 상담좀.. [4] 허허벌판갤로그로 이동합니다. 11.09.23 50 0
275145 진정한 보안은 서버사이드에서 해야지 쵸쵸(112.219) 11.09.23 43 0
275143 si 는 소울이 없다 쵸쵸(112.219) 11.09.23 56 0
275142 근데 아델형 보면 [12] 힙꼬맹갤로그로 이동합니다. 11.09.23 82 0
275141 우리학교교수는 Light search갤로그로 이동합니다. 11.09.23 63 0
275140 힙꼬맹 이세끼 보면 [9] Adelposs갤로그로 이동합니다. 11.09.23 81 0
275139 집에 반찬도 없어 배고파 디지겟네 [2] 힙꼬맹갤로그로 이동합니다. 11.09.23 41 0
275137 너희들도 존나 웃긴 교수 많지 않냐? [4] Adelposs갤로그로 이동합니다. 11.09.23 76 0
275135 형들 mfc100d.dll 은 vs안깔려있으면 답이없음? [1] 늘모(210.119) 11.09.23 6862 0
275134 그런데 금융권이 일반 si 중소기업보다 훨씬 낫지 않아? [2] 좋은아버지갤로그로 이동합니다. 11.09.23 104 0
275133 어플로 브라우저만드는데 값넘기기어째함? [10] ㅂㅈㄷ(210.178) 11.09.23 81 0
275130 인순이 추징금 9억이상 이모군(175.114) 11.09.23 44 0
275129 횽들 눕눕이좀 도와주세여; [5] 닥회드(175.112) 11.09.23 239 0
275128 아델아 그런 교수가 정말 있냐? [7] blackd갤로그로 이동합니다. 11.09.23 88 0
275127 금융쪽 업무는 살떨려서 하겠냐 [14] 쵸쵸(112.219) 11.09.23 130 0
275123 내가 기획과 개발에만 전념하다 보니 운영스킬이 전무하다# 쵸쵸(112.219) 11.09.23 48 0
275122 디시 실명인증하면 신용도 하락하냐? [1] 쵸쵸(112.219) 11.09.23 78 0
뉴스 ‘쇼윈도부부 의혹’ 김지우 “레이먼킴과 결혼 초부터 위기” 고백 디시트렌드 10:00
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2