Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- Oracle
- Java
- 암호화
- db
- 물리적주소
- Firebase
- window10
- eGov
- 알고리즘
- WebtoB
- dbms
- web server
- ua-parser
- programmers
- FCM
- @Scheduled
- 개발자도구
- TailMe
- WINDOW11
- JEUS
- AES
- 접근장치
- URLRewirte
- Was
- Login
- Tomcat
- User-Agent
- 브라우저
- scheduled
- mysql
Archives
- Today
- Total
HD
JAVA DB Connection (feat. mysql, oracle) 본문
반응형
MYSQL Connection
public static Connection getMySqlCon(String dbUser, String dbPwd, String schema) throws SQLException {
String url = "jdbc:mysql://localhost:3306/?characterEncoding=UTF-8&autoReconnect=true&autoReconnectForPools=true";
if(schema!=null) {
url = "jdbc:mysql://localhost:3306/"+schema+"?characterEncoding=UTF-8&autoReconnect=true&autoReconnectForPools=true";
}
String user = dbUser!=null?dbUser:"test";
String pwd = dbPwd!=null?dbPwd:"test1234";
Connection conn = null;
try {
Class.forName("org.gjt.mm.mysql.Driver");
conn = DriverManager.getConnection(url,user,pwd);
System.out.println("DB getExCon success!!");
} catch (Exception e){
e.printStackTrace();
System.out.println("DB getExCon Error!!");
}
return conn;
}
ORACLE Connection
public static Connection getOracleCon() throws SQLException {
String url = "jdbc:oracle:thin:@localhost:1521:orcl";
String user = "test";
String pwd = "test1234";
Connection conn = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(url,user,pwd);
System.out.println("DB getNewCon success!!");
} catch (Exception e){
e.printStackTrace();
System.out.println("DB getNewCon Error!!");
}
return conn;
}
반응형
'JAVA' 카테고리의 다른 글
URL로 첨부파일 다운로드 (0) | 2021.09.01 |
---|---|
이클립스 invalid LOC header 에러발생시 (0) | 2021.05.26 |
PHP 직렬화 -> JAVA 데이터 변환 (feat.pherialize-1.2.4.jar) (0) | 2020.12.28 |
SSLHandshakeException 오류 (0) | 2020.04.27 |
referer를 사용 한 이전 URL 가져오기 (feat.referer) (0) | 2019.11.06 |
Comments