1
빠른 질문이 있습니다. 저는 초보자 프로그래머이고 학교에서는 콘솔의 쿼리 결과를 출력하는 작은 콘솔 코드를 만들어야합니다. 얼마나 많은 노력을했는지 모르겠지만 쿼리 결과 대신 이상한 텍스트가 나옵니다.데이터베이스에서 콘솔 프로그램으로 정보 인쇄
여기 내 메인 클래스가있어, 나는 또한 (이 클래스는 MySQL 데이터베이스에 연결을 만들기위한 코드를 보유하고 SimpleDataSourceV2
라고 두 번째 클래스가 있습니다.
public static void main(String[] args) {
try {
Connection conn = SimpleDataSourceV2.getConnection();
doQuery(conn);
conn.close();
}
catch (Exception e){
System.out.print(e);
}
}
public static void doQuery(Connection conn) {
try {
Statement stat = conn.createStatement();
ResultSet result = stat.executeQuery("SELECT * FROM employee");
while (result.next()) {
System.out.println(result);
}
result.close();
stat.close();
}
catch (SQLException e){
System.out.print(e);
}
}
를이 내가.를 사용하는 두 가지 방법이 있습니다
run:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
BUILD SUCCESSFUL (total time: 1 second)
수있는 사람하십시오 직원 테이블
여기내 출력은 무엇인가 등의 이름, ADRESS, 도시, 서로 다른 정보를 보유 내가 뭘 잘못하고 있다고 말해?
미리 감사드립니다.