이클립스랑 Mysql을 연동해야 하는데
연동은 했는데 결과값이 출력이 안 됩니다...뭐가 문제일까요?
고수님들 도와주시면 감사하겠습니다.
코드 :
package databaseLab;
import java.sql.*;
public class jdbctext {
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://127.0.0.1:3306/sakila";
static final String USERNAME = "root";
static final String PASSWORD = "0000"; //비밀번호는 알맞게 넣었습니다..ㅎㅎ
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
try{
Class.forName(JDBC_DRIVER);
conn = DriverManager.getConnection(DB_URL,USERNAME,PASSWORD);
System.out.println("\n- MySQL Connection");
stmt = conn.createStatement();
String sql;
sql = "SELECT groupname, membername FROM idol";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
String groupName = rs.getString("groupName");
String memberName = rs.getString("memberName");
System.out.print("\n** Group : " + groupName);
System.out.print("\n -> Member: " + memberName);
}
rs.close();
stmt.close();
conn.close();
}catch(SQLException se1){
se1.printStackTrace();
}catch(Exception ex){
ex.printStackTrace();
}finally{
try{
if(stmt!=null)
stmt.close();
}catch(SQLException se2){
}
try{
if(conn!=null)
conn.close();
}catch(SQLException se){
se.printStackTrace();
}
}
System.out.println("\n\n- MySQL Connection Close");
}
}
결과값:
Tue May 03 22:11:56 KST 2016 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
- MySQL Connection
- MySQL Connection Close
원래 저 사이에
** Group : ses -> Member: vada ** Group : sistar -> Member: dasom
요래 떠야되는데...뭐가 문제인지 모르겠습니다 ㅠㅠ