'programming'에 해당되는 글 387건

  1. 2012.09.12 Oracle Connection Test / MySql Connection Test

반응형

 

 

<!-- Oracle Connection Test -->
<%@ page import="java.sql.*" contentType="text/html;charset=utf-8"%>
<%
String DB_URL = "jdbc:oracle:thin:@SERVER_IP:PORT:SID";
String DB_USER = "DB_USER";
String DB_PASSWORD= "DB_PASSWORD";
 
Connection conn;
Statement stmt;
 
try {
     Class.forName("oracle.jdbc.driver.OracleDriver");
     conn = DriverManager.getConnection(DB_URL, DB_USER, DB_PASSWORD);
     stmt = conn.createStatement();
     conn.close();
     out.println("oracle jdbc test: connect ok!!");
} catch(Exception e) {
     out.println(e.getMessage());
}
%>

 

 


<!-- MySql Connection Test -->
<%@ page import="java.sql.*" contentType="text/html;charset=utf-8"%>
<%
String DB_URL = "jdbc:mysql://SERVER_ID/DB_NAME";
String DB_USER = "DB_USER";
String DB_PASSWORD= "DB_PASSWORD";
 
Connection conn;
Statement stmt;
 
try {
     Class.forName("com.mysql.jdbc.Driver");
     conn = DriverManager.getConnection(DB_URL, DB_USER, DB_PASSWORD);
     stmt = conn.createStatement();
     conn.close();
     out.println("mysql jdbc test: connect ok!!");
} catch(Exception e) {
     out.println(e.getMessage());
}
%>


 

 

 

반응형
Posted by 공간사랑
,