Помогите invalid database adress

Статус
Закрыто для дальнейших ответов.
Ну лол, у тебя всё правильно, всё должно работать. Я думаю, что у тебя траблы из-за самой бд
 
В твоей ошибке ты вообще пытаешься к sqlite конектится. Приведи свой плагин в порядок. Доигрался со статиками называется.
 
Ошибка может возникнуть из-за недоработки в API? Версия 1.8.8-R0.1-SNAPSHOT
 
Дб пустая, таблиц нет.
В конфиге пробелов лишних не стоит?
Используешь MySQL Workbanch?
Попробуй сделать через нормальный класс, я использую кого-то немца
Код:
public class MySQL {

    private String Host;
    private String Database;
    private String Username;
    private String Password;
    private Connection connection;
    
    public MySQL(final String host, final String database, final String username, final String password) {
        this.Host = host;
        this.Database = database;
        this.Username = username;
        this.Password = password;
    }
    
    public void Connect() {
        try {
            Class.forName("com.mysql.jdbc.Driver");
        }
        catch (ClassNotFoundException e1) {
            System.out.println("[MySQLAPI] Fehler 01");
            System.out.println("[MySQLAPI] Es fehlen benoetigte Klassen!");
            e1.printStackTrace();
        }
        //final String url = "jdbc:mysql://" + this.Host + ":3306/" + this.Database + "?characterEncoding=latin1&useConfigs=maxPerformance";
        final String url = "jdbc:mysql://" + this.Host + ":3306/" + this.Database + "?useUnicode=true&characterEncoding=utf-8";
        try {
            this.connection = DriverManager.getConnection(url, this.Username, this.Password);
        }
        catch (SQLException e2) {
            System.out.println("[MySQLAPI] Fehler 02");
            System.out.println("[MySQLAPI] Es ist ein Fehler bei der Verbindung aufgetreten!");
            e2.printStackTrace();
        }
    }
    
    public void Disconnect() {
        try {
            if (!this.connection.isClosed() && this.connection != null) {
                this.connection.close();
                System.out.println("[MySQLAPI] Die Verbindung zum MySQL-Server wurde erfolgreich getrennt!");
            }
            else {
                System.out.println("[MySQLAPI] Die Verbindung ist bereits getrennt!");
            }
        }
        catch (SQLException e3) {
            System.out.println("[MySQLAPI] Fehler 03");
            System.out.println("[MySQLAPI] Es ist ein Fehler beim trennen der Verbindung aufgetreten!");
            e3.printStackTrace();
        }
    }
    
    public ResultSet GetResult(final String command) {
        try {
            if (this.connection.isClosed()) {
                this.Connect();
            }
            final Statement st = this.connection.createStatement();
            st.executeQuery(command);
            final ResultSet rs = st.getResultSet();
            return rs;
        }
        catch (SQLException e4) {
            System.out.println("[MySQLAPI] Fehler 04");
            System.out.println("[MySQLAPI] Es ist ein Fehler beim Ausfuehren des Befehls aufgetreten!");
            e4.printStackTrace();
            return null;
        }
    }
    
    public void ExecuteCommand(final String command) {
        try {
            if (this.connection.isClosed()) {
                this.Connect();
            }
            final Statement st = this.connection.createStatement();
            st.executeUpdate(command);
        }
        catch (SQLException e5) {
            System.out.println("[MySQLAPI] Fehler 04");
            System.out.println("[MySQLAPI] Es ist ein Fehler beim Ausfuehren des Befehls aufgetreten!");
            e5.printStackTrace();
        }
    }
    public Connection getConnection() {
        return this.connection;
    }
}
 
Последнее редактирование:
В конфиге пробелов лишних не стоит?
Используешь MySQL Workbanch?
Попробуй сделать через нормальный класс, я использую кого-то немца
Код:
public class MySQL {

    private String Host;
    private String Database;
    private String Username;
    private String Password;
    private Connection connection;
   
    public MySQL(final String host, final String database, final String username, final String password) {
        this.Host = host;
        this.Database = database;
        this.Username = username;
        this.Password = password;
    }
   
    public void Connect() {
        try {
            Class.forName("com.mysql.jdbc.Driver");
        }
        catch (ClassNotFoundException e1) {
            System.out.println("[MySQLAPI] Fehler 01");
            System.out.println("[MySQLAPI] Es fehlen benoetigte Klassen!");
            e1.printStackTrace();
        }
        //final String url = "jdbc:mysql://" + this.Host + ":3306/" + this.Database + "?characterEncoding=latin1&useConfigs=maxPerformance";
        final String url = "jdbc:mysql://" + this.Host + ":3306/" + this.Database + "?useUnicode=true&characterEncoding=utf-8";
        try {
            this.connection = DriverManager.getConnection(url, this.Username, this.Password);
        }
        catch (SQLException e2) {
            System.out.println("[MySQLAPI] Fehler 02");
            System.out.println("[MySQLAPI] Es ist ein Fehler bei der Verbindung aufgetreten!");
            e2.printStackTrace();
        }
    }
   
    public void Disconnect() {
        try {
            if (!this.connection.isClosed() && this.connection != null) {
                this.connection.close();
                System.out.println("[MySQLAPI] Die Verbindung zum MySQL-Server wurde erfolgreich getrennt!");
            }
            else {
                System.out.println("[MySQLAPI] Die Verbindung ist bereits getrennt!");
            }
        }
        catch (SQLException e3) {
            System.out.println("[MySQLAPI] Fehler 03");
            System.out.println("[MySQLAPI] Es ist ein Fehler beim trennen der Verbindung aufgetreten!");
            e3.printStackTrace();
        }
    }
   
    public ResultSet GetResult(final String command) {
        try {
            if (this.connection.isClosed()) {
                this.Connect();
            }
            final Statement st = this.connection.createStatement();
            st.executeQuery(command);
            final ResultSet rs = st.getResultSet();
            return rs;
        }
        catch (SQLException e4) {
            System.out.println("[MySQLAPI] Fehler 04");
            System.out.println("[MySQLAPI] Es ist ein Fehler beim Ausfuehren des Befehls aufgetreten!");
            e4.printStackTrace();
            return null;
        }
    }
   
    public void ExecuteCommand(final String command) {
        try {
            if (this.connection.isClosed()) {
                this.Connect();
            }
            final Statement st = this.connection.createStatement();
            st.executeUpdate(command);
        }
        catch (SQLException e5) {
            System.out.println("[MySQLAPI] Fehler 04");
            System.out.println("[MySQLAPI] Es ist ein Fehler beim Ausfuehren des Befehls aufgetreten!");
            e5.printStackTrace();
        }
    }
    public Connection getConnection() {
        return this.connection;
    }
}
Ага, хороший класс с методами, названия которых начинаются с больших букв)
 
В конфиге пробелов лишних не стоит?
Используешь MySQL Workbanch?
Попробуй сделать через нормальный класс, я использую кого-то немца
Код:
public class MySQL {

    private String Host;
    private String Database;
    private String Username;
    private String Password;
    private Connection connection;
   
    public MySQL(final String host, final String database, final String username, final String password) {
        this.Host = host;
        this.Database = database;
        this.Username = username;
        this.Password = password;
    }
   
    public void Connect() {
        try {
            Class.forName("com.mysql.jdbc.Driver");
        }
        catch (ClassNotFoundException e1) {
            System.out.println("[MySQLAPI] Fehler 01");
            System.out.println("[MySQLAPI] Es fehlen benoetigte Klassen!");
            e1.printStackTrace();
        }
        //final String url = "jdbc:mysql://" + this.Host + ":3306/" + this.Database + "?characterEncoding=latin1&useConfigs=maxPerformance";
        final String url = "jdbc:mysql://" + this.Host + ":3306/" + this.Database + "?useUnicode=true&characterEncoding=utf-8";
        try {
            this.connection = DriverManager.getConnection(url, this.Username, this.Password);
        }
        catch (SQLException e2) {
            System.out.println("[MySQLAPI] Fehler 02");
            System.out.println("[MySQLAPI] Es ist ein Fehler bei der Verbindung aufgetreten!");
            e2.printStackTrace();
        }
    }
   
    public void Disconnect() {
        try {
            if (!this.connection.isClosed() && this.connection != null) {
                this.connection.close();
                System.out.println("[MySQLAPI] Die Verbindung zum MySQL-Server wurde erfolgreich getrennt!");
            }
            else {
                System.out.println("[MySQLAPI] Die Verbindung ist bereits getrennt!");
            }
        }
        catch (SQLException e3) {
            System.out.println("[MySQLAPI] Fehler 03");
            System.out.println("[MySQLAPI] Es ist ein Fehler beim trennen der Verbindung aufgetreten!");
            e3.printStackTrace();
        }
    }
   
    public ResultSet GetResult(final String command) {
        try {
            if (this.connection.isClosed()) {
                this.Connect();
            }
            final Statement st = this.connection.createStatement();
            st.executeQuery(command);
            final ResultSet rs = st.getResultSet();
            return rs;
        }
        catch (SQLException e4) {
            System.out.println("[MySQLAPI] Fehler 04");
            System.out.println("[MySQLAPI] Es ist ein Fehler beim Ausfuehren des Befehls aufgetreten!");
            e4.printStackTrace();
            return null;
        }
    }
   
    public void ExecuteCommand(final String command) {
        try {
            if (this.connection.isClosed()) {
                this.Connect();
            }
            final Statement st = this.connection.createStatement();
            st.executeUpdate(command);
        }
        catch (SQLException e5) {
            System.out.println("[MySQLAPI] Fehler 04");
            System.out.println("[MySQLAPI] Es ist ein Fehler beim Ausfuehren des Befehls aufgetreten!");
            e5.printStackTrace();
        }
    }
    public Connection getConnection() {
        return this.connection;
    }
}
Попробовал.. Не помогло(
 
боже, сделай просто main class с коннектом, запусти из ide под дебагом, и посмотри что происходит в DriverManager.
там цикл по драйверам разным, проверь есть ли среди них драйвер мускула и что происходит при попытке его использовать
 
боже, сделай просто main class с коннектом, запусти из ide под дебагом, и посмотри что происходит в DriverManager.
там цикл по драйверам разным, проверь есть ли среди них драйвер мускула и что происходит при попытке его использовать
Уже не нужно. Я решил использовать sqlite.
 
Статус
Закрыто для дальнейших ответов.
Назад
Верх