- Баллы
- 36
Это было в отдельном классе, но повторюсь, много проб, ошибок и т.д.Тебя не учили с классами работать да?
Следуйте инструкциям в видео ниже, чтобы узнать, как установить наш сайт как веб-приложение на главный экран вашего устройства.
Примечание: Эта функция может быть недоступна в некоторых браузерах.
Это было в отдельном классе, но повторюсь, много проб, ошибок и т.д.Тебя не учили с классами работать да?
Возьми мой класс и под себя переделай.Это было в отдельном классе, но повторюсь, много проб, ошибок и т.д.
Проверил весь плагин. Нигде нет признаков sqlite...В твоей ошибке ты вообще пытаешься к sqlite конектится. Приведи свой плагин в порядок. Доигрался со статиками называется.
Нет, скинь скрин развернутой дб, мб ты подключаешься к таблице?Ошибка может возникнуть из-за недоработки в API? Версия 1.8.8-R0.1-SNAPSHOT
Дб пустая, таблиц нет.Нет, скинь скрин развернутой дб, мб ты подключаешься к таблице?
В конфиге пробелов лишних не стоит?Дб пустая, таблиц нет.
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;
}
}
Проверяй лучше.Проверил весь плагин. Нигде нет признаков sqlite...
Ага, хороший класс с методами, названия которых начинаются с больших букв)В конфиге пробелов лишних не стоит?
Используешь 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; } }
Я раньше устанавливал sqlite на пк. Может он конфликтует?Проверяй лучше.
Уже не нужно. Я решил использовать sqlite.боже, сделай просто main class с коннектом, запусти из ide под дебагом, и посмотри что происходит в DriverManager.
там цикл по драйверам разным, проверь есть ли среди них драйвер мускула и что происходит при попытке его использовать