데이터베이스에서 읽기를 구성 할 수 있습니까? 나는 창문 아래있다. java.sql.SQLException의 :MySQL 데이터베이스에서 읽는 방법
public class JavaApplication10 {
public static void main(String[] args) {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
Properties connInfo = new Properties();
connInfo.put("characterEncoding","UTF8");
connInfo.put("user", "root");
connInfo.put("password", "goskomstat");
conn = DriverManager.getConnection("localhost", connInfo);
Windows 명령 줄에있는 내가 입력 할 수 있습니다 : C이 내 코드에서 발췌 한 로컬 호스트
에 대한 찾을 수 없습니다 적합 드라이버 는이 오류 메시지가 : \ Program Files \ MySQL \ MySQL 서버 5.6 \ bin> mysql -u root -p
그러면 암호 'goskomstat'를 작성하고 데이터베이스를 조작 할 수 있습니다.
나에게 무엇을 할 지 알려줄 수 있습니까? 당신이 특정 URI 접두사를 사용하여 JDBC 드라이버를 지정할 수 있습니다
conn = DriverManager.getConnection("jdbc:mysql://localhost/", connInfo);
을 다음과 같이
http://dev.mysql.com/downloads/connector/j/ : MySQL JDBC 드라이버가 필요하며 해당 URL 및 코드를 사용해야합니다. 설명서에 설명되어 있습니다. –