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 |
Tags
- 알고리즘
- TailMe
- @Scheduled
- FCM
- web server
- Firebase
- WebtoB
- Oracle
- Was
- 개발자도구
- URLRewirte
- User-Agent
- db
- 암호화
- ua-parser
- Tomcat
- WINDOW11
- Login
- 브라우저
- AES
- window10
- Java
- programmers
- scheduled
- 접근장치
- eGov
- mysql
- 물리적주소
- dbms
- JEUS
Archives
- Today
- Total
HD
JAVA DB Connection (feat. mysql, oracle) 본문
반응형
MYSQL Connection
mysql-connector-java-5.1.48.jar
0.96MB
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
ojdbc6.jar
2.61MB
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