도와 주실 수 있습니까? 이미 jdbc 빌드 경로를 수행하고 DB savetime이 존재합니다.데이터베이스 서버에 연결할 수 없습니다 - 이클립스 MySQL 오류
내 수업 :
package br.com.savetime;
import java.sql.*;
public class CriarConexao {
private static Connection con = null;
public static Connection abrirBanco(){
Connection con;
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/savetime", "root", "root");
System.out.println("conectando");
return con;
}
catch(ClassNotFoundException cnfe){
System.out.println("driver nao encontrado: " + cnfe.getMessage());
return null;
}
catch(SQLException sql){
System.out.println("SQLException: " + sql.getMessage());
System.out.println("SQLState: " + sql.getSQLState());
System.out.println("Erro: " + sql.getErrorCode());
System.out.println("StackTrace: " + sql.getStackTrace());
return null;
}
catch(Exception e){
System.out.println(e.getMessage());
return null;
}
}
public static void fecharBDcon(){
try{
con.close();
}
catch(Exception e){
System.out.println("erro ao fechar o banco" + e.getMessage());
}
}
}
내 오류 : 코드가 잘 작동
06-17 03:55:07.139: I/System.out(1367): SQLException: Could not create connection to database server.
06-17 03:55:07.139: I/System.out(1367): SQLState: 08001
06-17 03:55:07.139: I/System.out(1367): Erro: 0
06-17 03:55:07.149: I/System.out(1367): StackTrace: [Ljava.lang.StackTraceElement;@41bc1af0
"SQLException : 데이터베이스에 연결할 수 없습니다"- 관련이있는 것 같습니다. vant – user2864740
당신의 classpath에 당신의 운전병 단지가 있습니까? – NaaN
읽기 : [* Common Problems and Solutions *] (http://dev.mysql.com/doc/refman/5.0/es/connector-j-usagenotes-troubleshooting.html#qandaitem-25-4-5-3 -1-1) –