Tech Story/IoT

MySQL 접속테스트

슈퍼맨짱 2018. 6. 18. 11:25

MySQL접속테스트 (mysql_conn.jsp)


Tomcat-mysql 설치후 연결테스트


<%@ page import="java.sql.*" contentType="text/html;charset=utf-8"%>


 <%

         String DB_URL = "jdbc:mysql://localhost/mysql";

         String DB_USER = "ID";

         String DB_PASSWORD= "PASSWD";

         Connection conn;

         Statement stmt;


         try {

              Class.forName("org.gjt.mm.mysql.Driver");     // CLASSPATH에 mysql-connector.jar 를 복사하여 넣어줘야 함

              conn = DriverManager.getConnection(DB_URL, DB_USER, DB_PASSWORD);

              stmt = conn.createStatement();

              conn.close();

              out.println("MySQL Connection Success!");

         }

         catch(Exception e){

              out.println(e);

         }

 %>



[해당파일]

https://github.com/e3jake/DustProject