본문 바로가기
Error/jsp

이클리스와 mysql 연동 오류 해결

by 흰힌 2018. 7. 23.

<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ page import="java.sql.*" %>
<%
 Connection conn=null;
 
 String driver="com.mysql.jdbc.Driver";
 String url="jdbc:mysql://localhost:3306/testDB?serverTimezone=UTC";
 
 Boolean connect=false;
 
 try{
  Class.forName(driver);
  conn=DriverManager.getConnection(url,"java","java");
  
  connect=true;
  
  conn.close();
 }catch(Exception e){
  connect=false;
  e.printStackTrace();
 }
%>
<html>
<head>
<title>JDBC 연동 테스트 예제</title>
</head>
<body>
<h3>
<%if(connect==true){ %>
 연결되었습니다.
<%}else{ %>
 연결에 실패하였습니다.
<%} %>
</h3>
</body>
</html>

 


* url뒤에 ?serverTimezone=UTC 추가

 

String url="jdbc:mysql://localhost:3306/testDB?serverTimezone=UTC";

 

 

댓글