헤르메스 LIFE

JDBC 버전확인 본문

Core Java

JDBC 버전확인

헤르메스의날개 2020. 12. 17. 00:25
728x90

<%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%>
<%@ page import="java.sql.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<%
  StringBuffer sbError = new StringBuffer();
  DatabaseMetaData dbMetaData = null;
  Connection conn = null;
%>
<font size="-1"><p>
<%
  DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
  try {
    conn = DriverManager.getConnection("jdbc:oracle:thin:@111.111.111.111:1521:test", "scott", "tiger");
    dbMetaData = conn.getMetaData();
%>
<p>
Name of JDBC Driver : <%= dbMetaData.getDriverName() %><br>
Driver Version : <%= dbMetaData.getDriverVersion() %><br>
Major Version : <%= dbMetaData.getDriverMajorVersion() %><br>
Minor Version : <%= dbMetaData.getDriverMinorVersion() %><br>
<p>
Database Product Name : <%= dbMetaData.getDatabaseProductName() %><br>
Database Product Version Version : <%= dbMetaData.getDatabaseProductVersion() %><br>
Database Major Version: <%= dbMetaData.getDatabaseMajorVersion() %><br>
Database Minot Version: <%= dbMetaData.getDatabaseMinorVersion() %><br>
<%
  } catch (SQLException e) {
    sbError.append(e.toString());
  } finally {
    if (conn != null) {
      try {
        conn.close();
      } catch (SQLException e) {
        sbError.append(e.toString());
      }
    }
  }
  if (sbError.length() != 0) {
    out.println(sbError.toString());
  } else {
%>
<p></font>
<%
  }
%>
</body>
</html>

728x90