까먹지 말자! 자주 보자!
JSP BOARDER(3)_(ConnectionFactory .java) 본문
package board;
import java.sql.*;
public class ConnectionFactory {
private static ConnectionFactory connectionFactory = new ConnectionFactory();
private ConnectionFactory(){};
public static ConnectionFactory getDefaultFactory(){
if(connectionFactory == null){
connectionFactory = new ConnectionFactory();
}
return connectionFactory;
}
public static Connection createConnection(){
Connection connection = null;
try{
Class.forName("com.mysql.jdbc.Driver");
}catch(ClassNotFoundException cnfe){
System.out.println(cnfe);
}
String url = "jdbc:mysql://localhost:3306/noveljsp";
String user = "root";
String password = "123qwe123";
try {
connection = DriverManager.getConnection(url, user, password);
}catch(SQLException sqle){
System.out.println(sqle);
}
return connection;
}
}
'JSP' 카테고리의 다른 글
JSP BOARDER(5)_(boardAdmin_AdminLogin.jsp) (0) | 2016.05.24 |
---|---|
JSP BOARDER(4)_(ConnectionPool .java) (0) | 2016.05.24 |
JSP BOARDER(2)_(BoardData .java) (0) | 2016.05.24 |
JSP BOARDER(1)_게시판 관리를 위한 컴포넌트(AdminManager.java) (0) | 2016.05.24 |
request와 response의 동작과정 (0) | 2016.05.18 |