반응형

20140625_DriverLoading, DataBase Conntion IN java


1. 웹호스팅 중인 cafe24 DataBase로 접근 할 수 있도록 DriverLoading, DataBase Conntion.

2. 아래 소스 참고.


package driverdb;    //package명 미정 추후 수정함.

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.SQLException;


public class driverdbconn {

public Connection driverDbcon() throws ClassNotFoundException{

System.out.println("★ driverDbcon() : driverloading, dbconnection 성공 in driverDbcon()");


Connection conninmethod = null;

Class.forName("com.mysql.jdbc.Driver");

String jdbcDriver = "jdbc:mysql://umj64-003.cafe24.com:3306/xkgunjh?" +

"useUnicode=true&characterEncoding=utf-8";

String dbUser = "xkgunjh";

String dbPass = "********";      //패스워드 비공개

try {

conninmethod = DriverManager.getConnection(jdbcDriver, dbUser, dbPass);

}catch(SQLException e) {

e.printStackTrace();

}

return conninmethod;

}

}


반응형

+ Recent posts