DBService.java

Jmnote (토론 | 기여)님의 2019년 4월 18일 (목) 16:54 판 (새 문서: ==개요== <source lang='java'> public class DBService { private static DBService instance = null; private DBService() {} public static DBService getDB() { if (instance == null)...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

public class DBService {
	private static DBService instance = null;
	private DBService() {}
	public static DBService getDB() {
		if (instance == null) {
			synchronized (DBService.class) {
				if (instance == null) {
					instance = new DBService();
					instance.init();
				}
			}
		}
		return instance;
	}
	private Connection conn;
	public void init() {
		try {
			Class.forName("org.h2.Driver");
			conn = DriverManager.getConnection("jdbc:h2:~/test","sa","");
		} catch (SQLException e) {  
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

2 #

3 #

4 #

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}