디시인사이드 갤러리

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

갤러리 본문 영역

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

ㅇㅕ대생(124.55) 2011.09.23 00:01:48
조회 90 추천 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 - -
AD 디지털 액세서리 기간한정 세일! 운영자 25/07/11 - -
275944 사람 못구한다 못구한다 하는데 [4] Deanex갤로그로 이동합니다. 11.09.26 108 0
275942 아 시발 어그로끌꺼없나 .. Light search갤로그로 이동합니다. 11.09.26 59 0
275941 한국은 토건국가라 IT도 토건토건함여 ㅋㅋㅋ ;ㅅ;(211.222) 11.09.26 39 0
275940 아 외국인데 [5] 멸자(130.126) 11.09.26 74 0
275939 난 결국 linkedList를 알아버리고 말았다 ㅗ^_^ㅗ [3] lol(110.174) 11.09.26 96 0
275938 내 글로 더러워지 프겔을 정화한다!!!(뒤는 알아서 조심해!!) [2] 거칠게갤로그로 이동합니다. 11.09.26 70 0
275936 여기 플래시 액션하는 가이들 있음? [5] 신도림프리덤(112.171) 11.09.26 92 0
275935 C#좀 하는형들 제발 도와줘 [3] 잉여학생(210.102) 11.09.26 83 0
275933 야근비 따박따박 나오는 회사 있냐? [1] 신도림프리덤(112.171) 11.09.26 71 0
275932 지금 대기업들 10년이고 20년이고 후에 미국기업들 하청업체로 전락할꺼다 [2] .3(124.137) 11.09.26 88 0
275931 요즘 중소기업 개발자가 없다. 우리 회사 4달째 못구함 [4] 신도림프리덤(112.171) 11.09.26 134 0
275930 울나라 보안이 심각하긴 하구먼... [2] 분당살람갤로그로 이동합니다. 11.09.26 82 0
275929 거칠게 쟤는 왜이리 삼성까임 한페이지를 삼까글로 도배를 시켜놓넹 [2] -_-)(220.80) 11.09.26 66 1
275928 난 한국 사람들 병신같아보이던데 [1] 로하로하알로하갤로그로 이동합니다. 11.09.26 55 0
275926 우리 나라는 상생이라는 단어가 없다. [5] 거칠게갤로그로 이동합니다. 11.09.26 75 0
275925 아오 난 진정 삼성이 부끄럽다 ㅠㅠ [2] 거칠게갤로그로 이동합니다. 11.09.26 88 0
275924 형들 이것좀 봐줘 존나 간단한건데(C언어) [5] 얼빠진호랑이갤로그로 이동합니다. 11.09.26 132 0
275923 애플이 첨에 웹앱으로 했다가 뭔가 안되서 앱으로 전환했다는게 사실이야?? [1] 거칠게갤로그로 이동합니다. 11.09.26 72 0
275922 대기업에서 IT 개발인력 흡수 한다면 나도 대기업 써볼까??? [1] 거칠게갤로그로 이동합니다. 11.09.26 80 0
275921 티 브이넥 삿는데 [5] 로하로하알로하갤로그로 이동합니다. 11.09.26 51 0
275920 주변에 지인들 만나면 공통된 얘기가.. [5] .3(124.137) 11.09.26 102 0
275919 샘숭의 바다os도 자체 개발이 아닌 라이센스 샀다는게 사실인가염??? [3] 거칠게갤로그로 이동합니다. 11.09.26 95 0
275918 아이폰 홈키가 사망해서 리퍼 받았는데 이제는 뻑하면 수신 불가 ㅡㅡ 거칠게갤로그로 이동합니다. 11.09.26 53 0
275917 샘성 지금 2만명 모았데.. [2] .3(124.137) 11.09.26 92 0
275916 지금 여기 횽이 해준 그림들.. [1] McHello갤로그로 이동합니다. 11.09.26 61 0
275915 샘숭 sw 인재 육성하네 어쩌내 하더니 요즘은 잠잠하다?? 거칠게갤로그로 이동합니다. 11.09.26 61 0
275913 안드로이드 어플 개발은 포기 해야 하는 걸까?? [2] 거칠게갤로그로 이동합니다. 11.09.26 128 0
275912 어제 도서관에서 프로그래밍 클로져라는 책을 빌렸는데.. .3(124.137) 11.09.26 71 0
275911 이건가요 너무긴데.. [4] 헬프미(128.134) 11.09.26 56 0
275910 형들 C++ 에서 LinkedList 어떻게함? [2] lol(110.174) 11.09.26 61 0
275909 대털 4부에 해당하는게 대털 무대포라며? 분당살람갤로그로 이동합니다. 11.09.26 103 0
275908 씨언어 이거 작성어케해요 ㅠ [4] 헬프미(128.134) 11.09.26 70 0
275907 ldap 써본횽들? 씨발라드세요(112.216) 11.09.26 27 0
275903 프지기 오늘 아퍼서 쉼 [1] Adelposs갤로그로 이동합니다. 11.09.26 42 0
275897 헬스걸 이모군(175.114) 11.09.26 47 0
275896 이런거 불가능하냐..ㅠㅠ [1] McHello갤로그로 이동합니다. 11.09.26 88 0
275894 이것좀 해줘봐봐 괜찮은거 나오면 담에 맛있는거 사줌 [37] McHello갤로그로 이동합니다. 11.09.26 189 0
275893 쿄스케형의 바탕화면은 쓰레기와같다 [2] Light search갤로그로 이동합니다. 11.09.26 64 0
275892 내일 면접인대 [21] 면접보는사람(14.58) 11.09.26 170 0
275890 형들 c++로 주민번호판별 코드짠건데 자바로바꾸래 어떻게하지..? [4] 갓신갤로그로 이동합니다. 11.09.26 111 0
275889 얼호누나랑 사귀고싶다 [1] Light search갤로그로 이동합니다. 11.09.26 81 0
275888 winapi edit control에서 화면에 텍스트가 찍힐때 dc를.. [4] jini(125.7) 11.09.26 50 0
275887 공무원 마인드 [2] 123(125.7) 11.09.26 75 0
275885 나보다 바탕화면 지저분한 사람 있냐?? [16] 쿄스케갤로그로 이동합니다. 11.09.26 166 0
275884 얼빠진 호랑이는 고기를 사랑하빈다. [3] 얼빠진호랑이갤로그로 이동합니다. 11.09.26 95 0
275883 윗사람 중에 이런 사람 있음? [1] 123(125.7) 11.09.26 49 0
275882 얼호 아스횽이랑 곧 만남가질꺼가튼데 [3] Light search갤로그로 이동합니다. 11.09.26 67 0
275880 [c언어] while문 1+2+3 합계 구하는거 어케 함? ㅠㅠㅠ [11] ㅜㅠ(222.104) 11.09.26 92 0
275879 아스형도 디씨폐인이네 얼빠진호랑이갤로그로 이동합니다. 11.09.26 70 0
275876 c 구조체와 포인터, 값 할당에 대해 질문 ㅁㄴㄻㄹ갤로그로 이동합니다. 11.09.26 44 0
뉴스 밴드 실리카겔, 새 싱글 ‘南宮FEFERE’ 발매 이어 단독 콘서트 ‘Syn.THE.Size X’ 개최 디시트렌드 07.11
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2