디시인사이드 갤러리

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

갤러리 본문 영역

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

ㅇㅕ대생(124.55) 2011.09.23 00:01:48
조회 92 추천 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/21 - -
AD 곧 휴가!! 홈캉스, 바캉스 SALE 운영자 25/07/21 - -
275096 10000시간만 공부하면 전문가 될 수 있나?? [25] 컴돌이(211.60) 11.09.23 315 0
275095 나 알바 하는 피시방 쩐다 [8] Adelposs갤로그로 이동합니다. 11.09.23 103 0
275092 형들 OpenGL 빨간책 번역서 존나 오래전껀데 쓸만해? [2] +어게인갤로그로 이동합니다. 11.09.23 430 0
275085 지금 이걸보고 자짤얘기가 나오나효? [11] McHello갤로그로 이동합니다. 11.09.23 104 0
275083 형들 저 1학년인데 [4] 조선최고의짐꾼갤로그로 이동합니다. 11.09.23 68 0
275081 요가 그만 둔지 한달. [9] 이베지네이션(116.124) 11.09.23 145 0
275080 서치는 이치랑 무슨 관계임? [6] Adelposs갤로그로 이동합니다. 11.09.23 90 0
275079 한귀로듣고 한귀로흘려버림되지 그래도회식은 꼭참석해라 ㅇㅇ! [2] Light search갤로그로 이동합니다. 11.09.23 88 0
275078 ㅅㅂ 이렇게 라도 살고싶당 [3] 힙꼬맹갤로그로 이동합니다. 11.09.23 42 0
275076 고정짤은 역시 [1] 쿄스케갤로그로 이동합니다. 11.09.23 58 0
275075 나 프갤 문지기로 랩업하는게 어떨까? [3] Adelposs갤로그로 이동합니다. 11.09.23 52 0
275074 요즘 짤풍이 부네 ㅋㅋㅋ [4] Adelposs갤로그로 이동합니다. 11.09.23 81 0
275073 아 어제 잠안와서 디질뻔함 [3] 힙꼬맹갤로그로 이동합니다. 11.09.23 40 0
275072 형들 나 존나 나쁜세끼임? [6] Adelposs갤로그로 이동합니다. 11.09.23 64 0
275071 그런데 다들 고정 짤 있는거야? 나도 고정짤 만들어야 하나 ? [3] 좋은아버지갤로그로 이동합니다. 11.09.23 49 0
275070 우리도 회식 한번 하자. 장소는 프갤이니까 [2] 좋은아버지갤로그로 이동합니다. 11.09.23 57 0
275069 근데 회식 하면좋지않아? [15] Light search갤로그로 이동합니다. 11.09.23 139 0
275068 내앞에앉은 여자가맘에듬 Light search갤로그로 이동합니다. 11.09.23 65 0
275067 출근. 어제 칼퇴 했으니 오늘은 [8] 좋은아버지갤로그로 이동합니다. 11.09.23 69 0
275063 가을이다!!! [2] 쿄스케갤로그로 이동합니다. 11.09.23 65 0
275062 횽들 진짜 아무것도모르는 개초본데 서버관리하려고 ㅁㄴㄻㄴ(125.133) 11.09.23 30 0
275061 잠한숨도안자고학교간다 ㅅㅂ [4] Light search갤로그로 이동합니다. 11.09.23 67 0
275060 종종업계 이직금지 이런서약을 해야되나요 [2] 소스코드갤로그로 이동합니다. 11.09.23 154 0
275059 굿모닝~ 횽들아 IP충돌 질문좀 Kanon갤로그로 이동합니다. 11.09.23 100 0
275057 님들 이거 왜 안되는거죠?? 프로그래밍 초짜임.. [12] 칸토캣갤로그로 이동합니다. 11.09.23 130 1
275056 새벽반은 없었다 [1] SODMaster갤로그로 이동합니다. 11.09.23 43 0
275055 뭐야... 벌써들 자러간거야?! [1] 이문동쮸쮸바갤로그로 이동합니다. 11.09.23 77 0
275054 자바 진짜 쉬운거 ㅠㅠ 함만봐주세요 ㅠㅠ ㄴㅇㄹ(119.215) 11.09.23 43 0
275052 오늘은 이만퇴갤 Light search갤로그로 이동합니다. 11.09.23 22 0
275050 디씨에서 신상이나거론하고있고 하는짓뻔하네 [1] Light search갤로그로 이동합니다. 11.09.23 65 0
275048 저런새끼내옆에있었으면 진심 Light search갤로그로 이동합니다. 11.09.23 57 0
275047 보통 회사에서 석/박사 경력 환산이 어떻게 되냐? ㅁㄴㄻㄹ갤로그로 이동합니다. 11.09.23 71 0
275044 얼릉주무십숑 [1] 三didas갤로그로 이동합니다. 11.09.23 48 0
275042 로하짜응 까지말아라 [2] Adelposs갤로그로 이동합니다. 11.09.23 54 0
275039 번갈아가면서 쓰고있는데 [5] 三didas갤로그로 이동합니다. 11.09.23 65 0
275038 와 미친컴퓨터 고쳤다 ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ [3] 좋은아버지갤로그로 이동합니다. 11.09.23 75 0
275036 dot 횽 계시면 봐주세염 [1] 닥회드(110.13) 11.09.23 48 0
275035 아빠라는 사람은 오늘부로 나한테는 죽은 사람이다. [3] 로하로하알로하갤로그로 이동합니다. 11.09.23 118 0
275034 남녀의 생각차이. [3] 밤이네..(112.159) 11.09.23 89 0
275033 밥사먹을 돈이 없다 [8] Adelposs갤로그로 이동합니다. 11.09.23 78 0
275032 템플릿을 쓰지 않고 구현한 vector, queue 같은 자료구조 [7] 궁금이(121.129) 11.09.23 91 0
275030 내가 큰 프로젝트 경험이 많다 거수 씨발라드세요갤로그로 이동합니다. 11.09.23 65 0
275028 내가 알바하는 pc방 싸움 잘해보이는 형들밖에없어 [2] Adelposs갤로그로 이동합니다. 11.09.23 87 0
275027 봉수가 보고있다 시즌2 다시 부활했당 얄루 (61.106) 11.09.23 99 0
275026 뭐야 이글 [3] 지금,여기갤로그로 이동합니다. 11.09.23 68 0
275025 야 자바의 api들을 자바스크립트에서 활용할순없겠뉘.. 쵸쵸(219.251) 11.09.23 58 0
275024 횽아들 다시한번만 이거좀 봐주시옵소서..ㅠ [3] 닥회드(110.13) 11.09.23 50 0
275022 프로그래머들은 보통 얼굴이 크더라. [1] ㅇㅇ(222.107) 11.09.23 115 0
275021 엑세스 옜날버전에서 ㅇㅇ 0길이 허용이 null 맞지? kk(115.93) 11.09.23 37 0
275020 디버깅 창이 자꾸 꺼지네... 형들 도와줘ㅠ [9] 아스갤로그로 이동합니다. 11.09.23 104 0
뉴스 스테이씨, 23일 컴백 앞두고 타이틀곡 'I WANT IT' M/V 본편 선공개 디시트렌드 07.22
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2