디시인사이드 갤러리

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

갤러리 본문 영역

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

ㅇㅕ대생(124.55) 2011.09.23 00:01:48
조회 85 추천 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/06/30 - -
AD 휴대폰 바꿀까? 특가 구매 찬스! 운영자 25/07/02 - -
275323 윈7 파티션 옮겨서 새로깔면 인터넷 안되나여 응그래(112.155) 11.09.23 43 0
275321 usb 3.0 좋네 분당살람갤로그로 이동합니다. 11.09.23 53 0
275320 이건 어떻게 생각해야 하지? [3] blackd갤로그로 이동합니다. 11.09.23 103 0
275319 싱나는 금요일 저녁이다 [2] 지금,여기갤로그로 이동합니다. 11.09.23 59 0
275317 분명 한국어도 언어일텐데.. [6] ㅇㅇ(58.102) 11.09.23 99 0
275316 윈7쓰는데 자꾸 블루스크린 뜸여 ㅠㅠ [6] Radiohand갤로그로 이동합니다. 11.09.23 122 0
275315 여자들은 [5] 일광면갤로그로 이동합니다. 11.09.23 134 0
275314 아스야 27~30일중으로 케로로닭 만나면 [5] 쿄스케갤로그로 이동합니다. 11.09.23 77 0
275312 난 아이폰이 좋네 겔스가 좋네 하는 글들 보면 어이가 없더라 [1] ㅇㅇ(58.102) 11.09.23 54 0
275309 자바 코드좀 봐주세요.. [3] ㅁㄴ(220.78) 11.09.23 72 0
275308 디스어셈블러 질문 [3] 일광면갤로그로 이동합니다. 11.09.23 95 0
275306 아싸 회식!! [2] 쿄스케갤로그로 이동합니다. 11.09.23 64 0
275305 상암동에 신입 일할때가 딱히 없나? [1] 막장갤신학생갤로그로 이동합니다. 11.09.23 66 0
275304 은꼴에는 뒤 조심이라고 붙여라 좀 ㅠㅠ [2] 막장갤신학생갤로그로 이동합니다. 11.09.23 109 0
275302 횽들 매트랩 문제하나만 알려줘 ㅠㅠ [1] 공돌이(114.205) 11.09.23 1696 0
275300 너네들도 어차피 [5] 로하로하알로하갤로그로 이동합니다. 11.09.23 73 0
275299 로하로하알로하 어깨가 넓어서 키가 커보이면... [7] 이문동쮸쮸바갤로그로 이동합니다. 11.09.23 129 0
275297 아... 때려죽이고 싶다.. [5] ㅇㅇ(58.102) 11.09.23 76 0
275296 zum 인지 이거 괜찮은거 같네?? [1] 야요이갤로그로 이동합니다. 11.09.23 65 0
275295 키 하니까 생각낫는데 [1] 로하로하알로하갤로그로 이동합니다. 11.09.23 44 0
275294 나 생일이야.. [6] zeroxy갤로그로 이동합니다. 11.09.23 73 0
275292 존나 여기 아스 갤러리네. [1] SODMaster갤로그로 이동합니다. 11.09.23 57 0
275291 형들이 보기엔 게임기획자/웹마스터 어떰? [5] 힙꼬맹갤로그로 이동합니다. 11.09.23 97 0
275289 뭐랄까 여갤러오니 [2] 곰곰곰(121.188) 11.09.23 67 0
275285 금요일은 폭풍 실습에다가... [1] SODMaster갤로그로 이동합니다. 11.09.23 43 0
275282 프로그램개발만 빡신게 아닌듯... [3] .3(124.137) 11.09.23 89 0
275281 야 이거봐라 좆됐다 진짜.. [8] McHello갤로그로 이동합니다. 11.09.23 177 0
275280 짜증나고우울하네 [3] 三didas갤로그로 이동합니다. 11.09.23 73 0
275279 이클립스 질문좀요 야요이갤로그로 이동합니다. 11.09.23 37 0
275278 프갤 횽들 C언어 문제좀 봐조 ㅜㅜ [6] 디에라(116.124) 11.09.23 80 0
275276 체리키보드 청축이나아요 갈축이 나아요? [3] Light search갤로그로 이동합니다. 11.09.23 96 0
275275 2D게임 개발강좌 막겜개발 2강이 나왔어요 [9] McHello갤로그로 이동합니다. 11.09.23 143 0
275274 자바 txt파일 읽는거 질문이요 [1] ㅁㄴ(220.78) 11.09.23 100 0
275272 나는 이런 마음으로 사는데 형들 은 어때? [20] 좋은아버지갤로그로 이동합니다. 11.09.23 155 0
275271 jsp post로 넘겼을때 한글처리 문제 [2] jyp(210.110) 11.09.23 125 0
275270 곧있으면 내 생일이다. [4] 좋은아버지갤로그로 이동합니다. 11.09.23 62 0
275269 api에서 int형 전역변수는 어떻게 선언하나요? [4] ㅁㄴㅇ(222.121) 11.09.23 72 0
275268 프갤형님 지망을 하라는데 어디가 좋은가요? [3] ㅇㅇ(180.229) 11.09.23 146 0
275266 횽들 스마트폰으로 문자보낼때 이미지 파일 첨부 가능하잖아..? [7] 쿄스케갤로그로 이동합니다. 11.09.23 287 1
275265 xp랑 7이랑 CString 동작이 조금 다르네 [5] ㅁㄴㄻㄹ갤로그로 이동합니다. 11.09.23 85 0
275263 IT 용어 English to Korean 으로 잘 번역된 게 없을까? Deanex갤로그로 이동합니다. 11.09.23 43 0
275262 새로운라면을개발할ㄲㅏ? [4] 힙꼬맹갤로그로 이동합니다. 11.09.23 71 0
275261 대학원 Mac실의 위엄 [4] 분당살람갤로그로 이동합니다. 11.09.23 240 0
275260 알바가내글지웠네 혹시 프갤횽들중에체리키보드파실분 [1] Light search갤로그로 이동합니다. 11.09.23 64 0
275256 난 장편애니보단 단편 애니가 재밋드라 짱구같은거 [2] 힙꼬맹갤로그로 이동합니다. 11.09.23 87 0
275255 안드로이드 갤러리 잘 아는횽 좀 보긔요.. [2] 쿄스케갤로그로 이동합니다. 11.09.23 80 0
275254 sk컴즈가 sk플랫폼에 인수합병되면 경험자(113.10) 11.09.23 51 0
275253 으앙 이모가 문 잠그고 나감 힙꼬맹갤로그로 이동합니다. 11.09.23 46 0
275251 응용프로그래머들은 웹에대한 지식이 어느정도? [1] ㅋㅌㅊ(210.178) 11.09.23 107 0
275248 디쓰 존나 잼잇을듯 로하로하알로하갤로그로 이동합니다. 11.09.23 31 0
뉴스 주영훈, 제주 여행 중 찢어질 듯한 복통과 고열로 응급 수술 후 중환자실...현재 일반 병실서 회복 중 디시트렌드 07.05
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2